feat(ci-visibility): cache Go read requests and add git upload kill switch#4786
Conversation
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 7147dfc | Docs | Datadog PR Page | Give us feedback! |
5783264 to
4c138e0
Compare
BenchmarksBenchmark execution time: 2026-06-02 16:43:44 Comparing candidate commit 7147dfc in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 297 metrics, 2 unstable metrics, 1 flaky benchmarks without significant changes.
|
…d-cache # Conflicts: # internal/civisibility/utils/net/known_tests_api.go
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…witch (#4786) ### What does this PR do? Adds a best-effort, short-lived read cache for Go CI Visibility bootstrap requests. The cache covers successful decoded responses from: - settings - known tests - skippable tests - test-management tests The goal is to avoid repeating the same CI Visibility read/bootstrap network requests once per Go package test process in large `go test ./...` runs. The cache is scoped by repository/test context, endpoint, semantic request body, and either a local parent-process identity or an already-resolved CI identity. The implementation is fail-open: cache path, filesystem, lock, decode, validation, or staleness problems fall back to the existing live request path. Cache hits preserve decoded feature/test data and content-derived telemetry, while avoiding HTTP request telemetry because no network request happened. This PR also adds unit coverage for cache keying, TTL selection, storage validation, locking, endpoint behavior, and stale-owner protection. It adds integration coverage for preserving additional-feature initialization across cached reads, plus an E2E-style subprocess test that creates a temporary multi-package Go module and verifies `go test ./...` across multiple package test processes only hits the mock backend once per cacheable endpoint. This PR also adds `DD_CIVISIBILITY_GIT_UPLOAD_ENABLED` as a CI Visibility git upload kill switch. It defaults to `true`; setting it to `false` skips repository upload work while keeping CI Visibility enabled. Supported-configuration metadata is updated for this new environment variable. `CODEOWNERS`, module files, and non-CI Visibility packages are not changed. ### Motivation Large Go repositories can execute many package test binaries during `go test ./...`. Each package process currently pays the same CI Visibility bootstrap read cost even when the repository, commit, branch, service, environment, test configuration, and CI identity are identical. This optimization lets package test processes share those read responses for a short TTL through a local file cache, reducing repeated startup network work without changing feature behavior, span behavior, or returned backend data. ### Testing - [x] `go test ./internal/civisibility/integrations -run TestReadCacheSharesBootstrapAcrossGoTestPackages -count=1 -v` - [x] `go test ./internal/civisibility/utils/net ./internal/civisibility/integrations` - [x] `go test -race ./internal/civisibility/utils/net` - [x] `golangci-lint run ./internal/civisibility/utils/net ./internal/civisibility/integrations` - [x] `git diff --check` - [x] Verified touched files do not add direct `os.Getenv` / `os.LookupEnv` usage, raw `sync.Mutex` / `sync.RWMutex` usage, or new CI Visibility cache environment variables. ### Reviewer's Checklist <!-- * Authors can use this list as a reference to ensure that there are no problems during the review but the signing off is to be done by the reviewer(s). --> - [ ] Changed code has unit tests for its functionality at or near 100% coverage. - [ ] [System-Tests](https://github.com/DataDog/system-tests/) covering this feature have been added and enabled with the va.b.c-dev version tag. - [ ] There is a benchmark for any new code, or changes to existing code. - [ ] If this interacts with the agent in a new way, a system test has been added. - [ ] New code is free of linting errors. You can check this by running `make lint` locally. - [ ] New code doesn't break existing tests. You can check this by running `make test` locally. - [ ] Add an appropriate team label so this PR gets put in the right place for the release notes. - [ ] All generated files are up to date. You can check this by running `make generate` locally. - [ ] Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running `make fix-modules` locally. Co-authored-by: tony.redondo <[email protected]>
…witch (#4786) ### What does this PR do? Adds a best-effort, short-lived read cache for Go CI Visibility bootstrap requests. The cache covers successful decoded responses from: - settings - known tests - skippable tests - test-management tests The goal is to avoid repeating the same CI Visibility read/bootstrap network requests once per Go package test process in large `go test ./...` runs. The cache is scoped by repository/test context, endpoint, semantic request body, and either a local parent-process identity or an already-resolved CI identity. The implementation is fail-open: cache path, filesystem, lock, decode, validation, or staleness problems fall back to the existing live request path. Cache hits preserve decoded feature/test data and content-derived telemetry, while avoiding HTTP request telemetry because no network request happened. This PR also adds unit coverage for cache keying, TTL selection, storage validation, locking, endpoint behavior, and stale-owner protection. It adds integration coverage for preserving additional-feature initialization across cached reads, plus an E2E-style subprocess test that creates a temporary multi-package Go module and verifies `go test ./...` across multiple package test processes only hits the mock backend once per cacheable endpoint. This PR also adds `DD_CIVISIBILITY_GIT_UPLOAD_ENABLED` as a CI Visibility git upload kill switch. It defaults to `true`; setting it to `false` skips repository upload work while keeping CI Visibility enabled. Supported-configuration metadata is updated for this new environment variable. `CODEOWNERS`, module files, and non-CI Visibility packages are not changed. ### Motivation Large Go repositories can execute many package test binaries during `go test ./...`. Each package process currently pays the same CI Visibility bootstrap read cost even when the repository, commit, branch, service, environment, test configuration, and CI identity are identical. This optimization lets package test processes share those read responses for a short TTL through a local file cache, reducing repeated startup network work without changing feature behavior, span behavior, or returned backend data. ### Testing - [x] `go test ./internal/civisibility/integrations -run TestReadCacheSharesBootstrapAcrossGoTestPackages -count=1 -v` - [x] `go test ./internal/civisibility/utils/net ./internal/civisibility/integrations` - [x] `go test -race ./internal/civisibility/utils/net` - [x] `golangci-lint run ./internal/civisibility/utils/net ./internal/civisibility/integrations` - [x] `git diff --check` - [x] Verified touched files do not add direct `os.Getenv` / `os.LookupEnv` usage, raw `sync.Mutex` / `sync.RWMutex` usage, or new CI Visibility cache environment variables. ### Reviewer's Checklist <!-- * Authors can use this list as a reference to ensure that there are no problems during the review but the signing off is to be done by the reviewer(s). --> - [ ] Changed code has unit tests for its functionality at or near 100% coverage. - [ ] [System-Tests](https://github.com/DataDog/system-tests/) covering this feature have been added and enabled with the va.b.c-dev version tag. - [ ] There is a benchmark for any new code, or changes to existing code. - [ ] If this interacts with the agent in a new way, a system test has been added. - [ ] New code is free of linting errors. You can check this by running `make lint` locally. - [ ] New code doesn't break existing tests. You can check this by running `make test` locally. - [ ] Add an appropriate team label so this PR gets put in the right place for the release notes. - [ ] All generated files are up to date. You can check this by running `make generate` locally. - [ ] Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running `make fix-modules` locally. Co-authored-by: tony.redondo <[email protected]>
What does this PR do?
Adds a best-effort, short-lived read cache for Go CI Visibility bootstrap requests.
The cache covers successful decoded responses from:
The goal is to avoid repeating the same CI Visibility read/bootstrap network requests once per Go package test process in large
go test ./...runs. The cache is scoped by repository/test context, endpoint, semantic request body, and either a local parent-process identity or an already-resolved CI identity.The implementation is fail-open: cache path, filesystem, lock, decode, validation, or staleness problems fall back to the existing live request path. Cache hits preserve decoded feature/test data and content-derived telemetry, while avoiding HTTP request telemetry because no network request happened.
This PR also adds unit coverage for cache keying, TTL selection, storage validation, locking, endpoint behavior, and stale-owner protection. It adds integration coverage for preserving additional-feature initialization across cached reads, plus an E2E-style subprocess test that creates a temporary multi-package Go module and verifies
go test ./...across multiple package test processes only hits the mock backend once per cacheable endpoint.This PR also adds
DD_CIVISIBILITY_GIT_UPLOAD_ENABLEDas a CI Visibility git upload kill switch. It defaults totrue; setting it tofalseskips repository upload work while keeping CI Visibility enabled. Supported-configuration metadata is updated for this new environment variable.CODEOWNERS, module files, and non-CI Visibility packages are not changed.Motivation
Large Go repositories can execute many package test binaries during
go test ./.... Each package process currently pays the same CI Visibility bootstrap read cost even when the repository, commit, branch, service, environment, test configuration, and CI identity are identical.This optimization lets package test processes share those read responses for a short TTL through a local file cache, reducing repeated startup network work without changing feature behavior, span behavior, or returned backend data.
Testing
go test ./internal/civisibility/integrations -run TestReadCacheSharesBootstrapAcrossGoTestPackages -count=1 -vgo test ./internal/civisibility/utils/net ./internal/civisibility/integrationsgo test -race ./internal/civisibility/utils/netgolangci-lint run ./internal/civisibility/utils/net ./internal/civisibility/integrationsgit diff --checkos.Getenv/os.LookupEnvusage, rawsync.Mutex/sync.RWMutexusage, or new CI Visibility cache environment variables.Reviewer's Checklist
make lintlocally.make testlocally.make generatelocally.make fix-moduleslocally.