Skip to content

fix(tracer): skip stats concentrator in OTLP export mode#4609

Draft
mtoffl01 wants to merge 2 commits intomtoff/otlp-export-tracesfrom
mtoff/stats-disabled-otlp
Draft

fix(tracer): skip stats concentrator in OTLP export mode#4609
mtoffl01 wants to merge 2 commits intomtoff/otlp-export-tracesfrom
mtoff/stats-disabled-otlp

Conversation

@mtoffl01
Copy link
Copy Markdown
Contributor

@mtoffl01 mtoffl01 commented Mar 26, 2026

What does this PR do?

Skips initializing the stats concentrator when the tracer is running in OTLP export mode. Instead of creating the concentrator and letting it run idle, t.stats is left as nil. All *concentrator methods (Start, Stop, flushAndSend, newTracerStatSpan) are made nil-receiver safe so call sites don't need nil checks.

Motivation:

In OTLP export mode, traces are sent to an OpenTelemetry Collector — not the Datadog agent. The stats concentrator aggregates client-side stats and sends them to the agent's /v0.6/stats endpoint, which is unnecessary in this mode: either the user has no agent (using the collector exclusively), or they've opted to prioritize the collector. Keeping the concentrator running wastes CPU, memory, and goroutines on stats that are never consumed. This PR eliminates that overhead while ensuring all spans are still retained and delivered to the OTLP writer.

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.

Unsure? Have a question? Request a review!

@mtoffl01 mtoffl01 changed the base branch from main to mtoff/otlp-export-traces March 26, 2026 18:34
@@ -28,6 +28,8 @@ import (
"time"

"go.uber.org/goleak"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
File is not properly formatted (gofmt)

assert.True(t, trc.config.canDropP0s(), "canDropP0s must be true for this test to exercise submit()")

const spanCount = 5
for i := 0; i < spanCount; i++ {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
rangeint: for loop can be modernized using range over int (modernize)

@mtoffl01 mtoffl01 changed the title Allow Config to resolve traceURL; pass this as a field into httptrans… fix(tracer) Disable tracer.stats concentrator when in otlp mode Mar 26, 2026
@mtoffl01 mtoffl01 changed the title fix(tracer) Disable tracer.stats concentrator when in otlp mode fix(tracer): skip stats concentrator in OTLP export mode Mar 26, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.11%. Comparing base (c371138) to head (0e4f52b).

Additional details and impacted files
Files with missing lines Coverage Δ
ddtrace/tracer/stats.go 98.59% <100.00%> (+0.08%) ⬆️
ddtrace/tracer/tracer.go 88.97% <100.00%> (+0.06%) ⬆️

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

@datadog-datadog-prod-us1-2
Copy link
Copy Markdown

datadog-datadog-prod-us1-2 bot commented Mar 26, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 60.33% (+0.02%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 0e4f52b | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Mar 26, 2026

Benchmarks

Benchmark execution time: 2026-03-27 16:10:42

Comparing candidate commit 0e4f52b in PR branch mtoff/stats-disabled-otlp with baseline commit c371138 in branch mtoff/otlp-export-traces.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 214 metrics, 10 unstable metrics.

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 ----------------------------------'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant