Skip to content

feat(otel): Implement parentbased_always_on in otlp mode#4567

Merged
mtoffl01 merged 7 commits into
mainfrom
mtoff/otel-sampling
Mar 20, 2026
Merged

feat(otel): Implement parentbased_always_on in otlp mode#4567
mtoffl01 merged 7 commits into
mainfrom
mtoff/otel-sampling

Conversation

@mtoffl01

@mtoffl01 mtoffl01 commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Background

This PR is part of an ongoing effort to support OTLP Traces Export Phase 1, documented here. It contains some placeholder/no-op code (e.g. otlpTraceWriter) which will be implemented in follow-up PRs (e.g, #4522).

What does this PR do?

When OTLP export mode is enabled, the SDK must not use the Datadog Agent priority sampler, since there is no agent available to provide per-service sampling rates. This PR introduces a replacement fallback sampler for that mode.

New type: otelParentBasedAlwaysOnSampler — implements the parentbased_always_on strategy (ref), which honors propagated sampling decisions from parent contexts, otherwise samples all traces at rate 1.0. User-configured rules take precedence over this fallback.

New interface: defaultSampler — abstracts the fallback sampling strategy applied when no user-defined rules match a span. Both prioritySampler (agent mode) and otelParentBasedAlwaysOnSampler (OTLP mode) satisfy this interface, replacing the previous concrete *prioritySampler field on the tracer and ensuring the fallback is never nil.

Motivation

See Requirements: https://docs.google.com/document/d/1AsUrJxjJavLvSG33kUAJLYzGU8IYgrnf1SMbFDsuGmo/edit?tab=t.avgpmfl6f0c6#heading=h.nqkivnomx6oe

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 title feat feat(otel): Implement parentbased_always_on in otlp mode Mar 19, 2026
@datadog-datadog-prod-us1

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

Copy link
Copy Markdown

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 86.67%
Overall Coverage: 59.43% (+3.56%)

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

@codecov

codecov Bot commented Mar 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.15%. Comparing base (516cca3) to head (3ea6e13).

Files with missing lines Patch % Lines
ddtrace/tracer/otlp_writer.go 60.00% 2 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
ddtrace/tracer/option.go 83.92% <ø> (ø)
ddtrace/tracer/sampler.go 95.61% <100.00%> (ø)
ddtrace/tracer/tracer.go 88.72% <100.00%> (ø)
ddtrace/tracer/otlp_writer.go 60.00% <60.00%> (ø)

... and 434 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 Mar 19, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-03-20 18:13:48

Comparing candidate commit 3ea6e13 in PR branch mtoff/otel-sampling with baseline commit 516cca3 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 215 metrics, 9 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 ----------------------------------'

@mtoffl01
mtoffl01 marked this pull request as ready for review March 19, 2026 20:44
@mtoffl01
mtoffl01 requested review from a team as code owners March 19, 2026 20:44

@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

@darccio

darccio commented Mar 20, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

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

@rachelyangdog rachelyangdog left a comment

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.

Looks good to me!

@mtoffl01
mtoffl01 enabled auto-merge (squash) March 20, 2026 17:51
@mtoffl01
mtoffl01 merged commit 077471e into main Mar 20, 2026
115 checks passed
@mtoffl01
mtoffl01 deleted the mtoff/otel-sampling branch March 20, 2026 18:15
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.

3 participants