Skip to content

feat(ci-visibility): cache Go read requests and add git upload kill switch#4786

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 10 commits into
mainfrom
feat/civisibility-read-cache
Jun 2, 2026
Merged

feat(ci-visibility): cache Go read requests and add git upload kill switch#4786
gh-worker-dd-mergequeue-cf854d[bot] merged 10 commits into
mainfrom
feat/civisibility-read-cache

Conversation

@tonyredondo

@tonyredondo tonyredondo commented May 19, 2026

Copy link
Copy Markdown
Member

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

  • go test ./internal/civisibility/integrations -run TestReadCacheSharesBootstrapAcrossGoTestPackages -count=1 -v
  • go test ./internal/civisibility/utils/net ./internal/civisibility/integrations
  • go test -race ./internal/civisibility/utils/net
  • golangci-lint run ./internal/civisibility/utils/net ./internal/civisibility/integrations
  • git diff --check
  • 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

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • 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.

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented May 19, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 70.92%
Overall Coverage: 62.08% (+3.89%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 7147dfc | Docs | Datadog PR Page | Give us feedback!

@codecov

codecov Bot commented May 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.39884% with 191 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.76%. Comparing base (ee0a579) to head (7147dfc).

Files with missing lines Patch % Lines
internal/civisibility/utils/net/read_cache.go 68.51% 93 Missing and 49 partials ⚠️
internal/civisibility/utils/net/skippable.go 72.85% 8 Missing and 11 partials ⚠️
...ivisibility/utils/net/test_management_tests_api.go 72.34% 5 Missing and 8 partials ⚠️
internal/civisibility/utils/net/settings_api.go 82.69% 4 Missing and 5 partials ⚠️
internal/civisibility/utils/net/known_tests_api.go 85.71% 3 Missing and 5 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
...civisibility/integrations/civisibility_features.go 67.98% <100.00%> (ø)
internal/civisibility/utils/net/client.go 78.62% <100.00%> (ø)
internal/civisibility/utils/net/known_tests_api.go 84.40% <85.71%> (ø)
internal/civisibility/utils/net/settings_api.go 85.04% <82.69%> (ø)
...ivisibility/utils/net/test_management_tests_api.go 74.52% <72.34%> (ø)
internal/civisibility/utils/net/skippable.go 75.28% <72.85%> (ø)
internal/civisibility/utils/net/read_cache.go 68.51% <68.51%> (ø)

... and 447 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tonyredondo
tonyredondo force-pushed the feat/civisibility-read-cache branch from 5783264 to 4c138e0 Compare May 19, 2026 16:49
@pr-commenter

pr-commenter Bot commented May 19, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-06-02 16:43:44

Comparing candidate commit 7147dfc in PR branch feat/civisibility-read-cache with baseline commit ee0a579 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 297 metrics, 2 unstable metrics, 1 flaky benchmarks without significant changes.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

Known flaky benchmarks without significant changes:

  • scenario:BenchmarkOTLPTraceWriterFlush

@tonyredondo tonyredondo changed the title feat(ci-visibility): cache Go read bootstrap requests feat(ci-visibility): cache Go read requests and add git upload kill switch May 22, 2026
@tonyredondo
tonyredondo marked this pull request as ready for review May 22, 2026 13:17
@tonyredondo
tonyredondo requested review from a team as code owners May 22, 2026 13:17
@tonyredondo
tonyredondo requested a review from Copilot May 22, 2026 13:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

…d-cache

# Conflicts:
#	internal/civisibility/utils/net/known_tests_api.go
@tonyredondo

Copy link
Copy Markdown
Member Author

@codex review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • internal/env/supported_configurations.gen.go: Language not supported

Comment thread internal/civisibility/utils/net/test_management_tests_api.go
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@genesor genesor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 00e3ff8 into main Jun 2, 2026
164 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the feat/civisibility-read-cache branch June 2, 2026 17:00
anna-git pushed a commit that referenced this pull request Jun 9, 2026
…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]>
darccio pushed a commit that referenced this pull request Jun 25, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants