Documentation
¶
Index ¶
- Constants
- func CloseIdleConnections()
- func ResetReadCacheHooksForTesting()
- func SetReadCacheHooksForTesting(cacheRoot string, now func() time.Time, pid func() int, parentPID func() int, ...)
- type Client
- type FormFile
- type KnownTestsRequestData
- type KnownTestsResponseData
- type KnownTestsResponseDataModules
- type KnownTestsResponseDataSuites
- type RequestConfig
- type RequestHandler
- type Response
- type SettingsRequestData
- type SettingsResponseData
- type SkippableResponseDataAttributes
- type SkippableTestsResponse
- type TestManagementTestsResponseDataModules
- type TestManagementTestsResponseDataSuites
- type TestManagementTestsResponseDataTestProperties
- type TestManagementTestsResponseDataTestPropertiesAttributes
- type TestManagementTestsResponseDataTests
Constants ¶
const ( // DefaultMaxRetries is the default number of retries for a request. DefaultMaxRetries int = 3 // DefaultBackoff is the default backoff time for a request. DefaultBackoff time.Duration = 100 * time.Millisecond )
const ( ContentTypeJSON = "application/json" ContentTypeJSONAlternative = "application/vnd.api+json" ContentTypeOctetStream = "application/octet-stream" ContentTypeMessagePack = "application/msgpack" ContentEncodingGzip = "gzip" HeaderContentType = "Content-Type" HeaderContentEncoding = "Content-Encoding" HeaderAcceptEncoding = "Accept-Encoding" HeaderRateLimitReset = "x-ratelimit-reset" HTTPStatusTooManyRequests = 429 FormatJSON = "json" FormatMessagePack = "msgpack" )
Constants for common strings
const (
// FormatLCOV is the LCOV coverage report format accepted by the coverage report intake.
FormatLCOV = "lcov"
)
Variables ¶
This section is empty.
Functions ¶
func CloseIdleConnections ¶
func CloseIdleConnections()
CloseIdleConnections closes idle connections owned by the shared CI Visibility HTTP client. It is safe to call during shutdown after CI Visibility components have finished sending their final payloads.
func ResetReadCacheHooksForTesting ¶
func ResetReadCacheHooksForTesting()
ResetReadCacheHooksForTesting restores production read-cache hooks after internal tests.
Types ¶
type Client ¶
type Client interface {
GetSettings() (*SettingsResponseData, error)
GetKnownTests() (*KnownTestsResponseData, error)
GetCommits(localCommits []string) ([]string, error)
SendPackFiles(commitSha string, packFiles []string) (bytes int64, err error)
SendCoveragePayload(ciTestCovPayload io.Reader) error
SendCoveragePayloadWithFormat(ciTestCovPayload io.Reader, format string) error
SendCoverageReport(report io.Reader, format string) error
GetSkippableTests() (*SkippableTestsResponse, error)
GetTestManagementTests() (*TestManagementTestsResponseDataModules, error)
SendLogs(logsPayload io.Reader) error
}
Client is an interface for sending requests to the Datadog backend.
func NewClient ¶
func NewClient() Client
NewClient creates a new client with the default service name.
func NewClientForCodeCoverage ¶
func NewClientForCodeCoverage() Client
NewClientForCodeCoverage creates a new client for sending code coverage payloads.
func NewClientForCoverageReportUpload ¶
func NewClientForCoverageReportUpload() Client
NewClientForCoverageReportUpload creates a new client for sending code coverage reports.
func NewClientForLogs ¶
func NewClientForLogs() Client
NewClientForLogs creates a new client for sending logs payloads.
func NewClientWithServiceName ¶
NewClientWithServiceName creates a new client with the given service name.
func NewClientWithServiceNameAndSubdomain ¶
NewClientWithServiceNameAndSubdomain creates a new client with the given service name and subdomain.
type FormFile ¶
type FormFile struct {
FieldName string // The name of the form field
FileName string // The name of the file
Content any // The content of the file (can be []byte, map, struct, etc.)
ContentType string // The MIME type of the file (e.g., "application/json", "application/octet-stream")
}
FormFile represents a file to be uploaded in a multipart form request.
type KnownTestsRequestData ¶
type KnownTestsResponseData ¶
type KnownTestsResponseData struct {
Tests KnownTestsResponseDataModules `json:"tests"`
PageInfo *knownTestsResponsePageInfo `json:"page_info,omitempty"`
}
type KnownTestsResponseDataModules ¶
type KnownTestsResponseDataModules map[string]KnownTestsResponseDataSuites
type RequestConfig ¶
type RequestConfig struct {
Method string // HTTP method: GET or POST
URL string // Request URL
Headers map[string]string // Additional HTTP headers
Body any // Request body for JSON, MessagePack, or raw bytes
Format string // Format: "json" or "msgpack"
Compressed bool // Whether to use gzip compression
Files []FormFile // Files to be uploaded in a multipart form data request
MaxRetries int // Maximum number of retries
Backoff time.Duration // Initial backoff duration for retries
ExpectJSONResponse bool // When true, a 2xx response with a non-JSON Content-Type is retried instead of being returned as-is
}
RequestConfig holds configuration for a request.
type RequestHandler ¶
RequestHandler handles HTTP requests with retries and different formats.
func NewRequestHandler ¶
func NewRequestHandler() *RequestHandler
NewRequestHandler creates a new RequestHandler with a default HTTP client.
func NewRequestHandlerWithClient ¶
func NewRequestHandlerWithClient(client *http.Client) *RequestHandler
NewRequestHandlerWithClient creates a new RequestHandler with a custom http.Client
func (*RequestHandler) CloseIdleConnections ¶
func (rh *RequestHandler) CloseIdleConnections()
CloseIdleConnections closes idle connections owned by the request handler's HTTP client. Active requests are left running by the standard library.
func (*RequestHandler) SendRequest ¶
func (rh *RequestHandler) SendRequest(config RequestConfig) (*Response, error)
SendRequest sends an HTTP request based on the provided configuration.
type Response ¶
type Response struct {
Body []byte // Response body in raw format
Format string // Format of the response (json or msgpack)
StatusCode int // HTTP status code
CanUnmarshal bool // Whether the response body can be unmarshalled
Compressed bool // Whether to use gzip compression
}
Response represents the HTTP response with deserialization capabilities and status code.
type SettingsRequestData ¶
type SettingsResponseData ¶
type SettingsResponseData struct {
CodeCoverage bool `json:"code_coverage"`
CoverageReportUploadEnabled bool `json:"coverage_report_upload_enabled"`
EarlyFlakeDetection struct {
Enabled bool `json:"enabled"`
SlowTestRetries struct {
TenS int `json:"10s"`
ThirtyS int `json:"30s"`
FiveM int `json:"5m"`
FiveS int `json:"5s"`
} `json:"slow_test_retries"`
FaultySessionThreshold int `json:"faulty_session_threshold"`
} `json:"early_flake_detection"`
FlakyTestRetriesEnabled bool `json:"flaky_test_retries_enabled"`
ItrEnabled bool `json:"itr_enabled"`
RequireGit bool `json:"require_git"`
TestsSkipping bool `json:"tests_skipping"`
KnownTestsEnabled bool `json:"known_tests_enabled"`
ImpactedTestsEnabled bool `json:"impacted_tests_enabled"`
TestManagement struct {
Enabled bool `json:"enabled"`
AttemptToFixRetries int `json:"attempt_to_fix_retries"`
} `json:"test_management"`
SubtestFeaturesEnabled bool `json:"-"`
}
type SkippableTestsResponse ¶
type SkippableTestsResponse struct {
CorrelationID string
Skippables map[string]map[string][]SkippableResponseDataAttributes
Coverage map[string]*filebitmap.FileBitmap
CoveragePresent bool
CoverageBackfillSafe bool
CoverageBackfillReason string
ResponseTestsCount int
}
SkippableTestsResponse stores the skippable-tests response plus backend line coverage metadata used to decide whether coverage-active ITR skips can be applied safely.
type TestManagementTestsResponseDataModules ¶
type TestManagementTestsResponseDataModules struct {
Modules map[string]TestManagementTestsResponseDataSuites `json:"modules"`
}
type TestManagementTestsResponseDataSuites ¶
type TestManagementTestsResponseDataSuites struct {
Suites map[string]TestManagementTestsResponseDataTests `json:"suites"`
}
type TestManagementTestsResponseDataTestProperties ¶
type TestManagementTestsResponseDataTestProperties struct {
Properties TestManagementTestsResponseDataTestPropertiesAttributes `json:"properties"`
}
type TestManagementTestsResponseDataTests ¶
type TestManagementTestsResponseDataTests struct {
Tests map[string]TestManagementTestsResponseDataTestProperties `json:"tests"`
}