Skip to content

fix(ci-visibility): reduce Go test wrapper overhead#4738

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 8 commits into
mainfrom
feat/lightweight-go-test-wrapper
May 8, 2026
Merged

fix(ci-visibility): reduce Go test wrapper overhead#4738
gh-worker-dd-mergequeue-cf854d[bot] merged 8 commits into
mainfrom
feat/lightweight-go-test-wrapper

Conversation

@tonyredondo

Copy link
Copy Markdown
Member

What does this PR do?

Reduces unnecessary Go CI Visibility additional-feature wrapper usage while preserving Test Management, Early Flake Detection, Flaky Test Retry, and attempt-to-fix behavior.

This PR adds an effective additional-feature selector before runTestWithRetry so tests only enter retry isolation when a feature can actually affect that test. It routes disabled tests without attempt-to-fix through a lightweight metadata/skip path, avoids retry wrappers for exact Test Management matches where all directive values are false, and keeps session-level additional-feature initialization intact before early returns.

It also tightens feature ownership rules:

  • disabled and quarantined tests without attempt-to-fix no longer let EFD or FTR own retry behavior
  • attempt-to-fix takes precedence over EFD/FTR for retry count, scheduler selection, retry reason, and final result propagation
  • subtests with exact all-false metadata can clear inherited attempt-to-fix retry-control metadata without losing inherited disabled/quarantine state
  • internal parallel EFD now uses an effective post-first-execution decision, installs a real mutex only for the bounded parallel branch, and no longer lets the raw environment flag leak into isEfdInParallel

No new environment variables are introduced; the implementation keeps using the existing internal parallel EFD flag.

Motivation

The Go CI Visibility wrapper can perturb scheduling-sensitive tests because retry-capable executions clone testing.T, run the test body in an extra goroutine, and can add retry or parallel retry scheduling. Some tests entered that heavy path only because a feature was globally enabled or because an exact Test Management record existed, even when no active directive or effective retry budget applied to the specific test.

The goal is to keep normal tests on the normal Go testing path, keep disabled tests from executing when they do not need attempt-to-fix, and avoid stacking unrelated retry behavior on top of Test Management semantics.

Testing

  • go test -count=1 ./internal/civisibility/integrations/gotesting
  • go test -count=1 ./internal/civisibility/integrations/gotesting/subtests
  • go test -count=1 ./internal/civisibility/integrations/gotesting/failnow
  • go test -count=1 ./internal/civisibility/integrations
  • go test -count=1 ./internal/env
  • go run ./scripts/configinverter/main.go check
  • git diff --check
  • Verified the rejected EFD kill switch and parallel EFD max-concurrency environment variables are not present in internal/civisibility or internal/env.

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-prod-us1-5

This comment has been minimized.

@codecov

codecov Bot commented May 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.06098% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.47%. Comparing base (7a6f899) to head (4837cb3).

Files with missing lines Patch % Lines
...sibility/integrations/gotesting/instrumentation.go 84.77% 20 Missing and 10 partials ⚠️
internal/civisibility/integrations/civisibility.go 90.00% 4 Missing and 2 partials ⚠️
internal/civisibility/utils/net/client.go 0.00% 4 Missing ⚠️
internal/civisibility/utils/net/http.go 50.00% 2 Missing and 2 partials ⚠️
internal/civisibility/civisibility.go 0.00% 3 Missing ⚠️
...egrations/gotesting/instrumentation_orchestrion.go 0.00% 2 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
ddtrace/mocktracer/mocktracer.go 92.47% <100.00%> (+3.18%) ⬆️
internal/civisibility/envconfig/enabled.go 100.00% <100.00%> (ø)
...civisibility/integrations/civisibility_features.go 62.19% <100.00%> (-7.94%) ⬇️
...integrations/gotesting/coverage/coverage_writer.go 83.63% <100.00%> (-6.93%) ⬇️
...nal/civisibility/integrations/gotesting/testing.go 58.35% <100.00%> (-4.54%) ⬇️
...rnal/civisibility/integrations/logs/logs_writer.go 87.50% <100.00%> (-4.44%) ⬇️
...egrations/gotesting/instrumentation_orchestrion.go 29.27% <0.00%> (-3.58%) ⬇️
internal/civisibility/civisibility.go 0.00% <0.00%> (ø)
internal/civisibility/utils/net/client.go 78.47% <0.00%> (-5.82%) ⬇️
internal/civisibility/utils/net/http.go 73.93% <50.00%> (-9.26%) ⬇️
... and 2 more

... and 267 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.

@pr-commenter

pr-commenter Bot commented May 7, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-05-08 09:49:23

Comparing candidate commit 4837cb3 in PR branch feat/lightweight-go-test-wrapper with baseline commit 7a6f899 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 273 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 marked this pull request as ready for review May 7, 2026 15:56
@tonyredondo
tonyredondo requested review from a team as code owners May 7, 2026 15:56

@darccio darccio 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

@tonyredondo
tonyredondo requested a review from a team as a code owner May 7, 2026 21:40
@tonyredondo
tonyredondo force-pushed the feat/lightweight-go-test-wrapper branch from b8eb66a to 08f634b Compare May 8, 2026 09:00
@tonyredondo
tonyredondo force-pushed the feat/lightweight-go-test-wrapper branch from 08f634b to 4837cb3 Compare May 8, 2026 09:25
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 252431a into main May 8, 2026
164 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the feat/lightweight-go-test-wrapper branch May 8, 2026 10:32
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.

3 participants