Skip to content

feat(otel): otel sampling support in distributed tracing - #4177

Merged
vpellan merged 29 commits into
masterfrom
vpellan/otel-threshold-random-value
Sep 30, 2026
Merged

vpellan merged 29 commits into
masterfrom
vpellan/otel-threshold-random-value

Conversation

@vpellan

@vpellan vpellan commented Sep 9, 2026

Copy link
Copy Markdown

Description

Add support for OTel sampling in distributed tracing, by reading and emitting ot.th and ot.rv tags. These tags will be forwarded to services using OTel SDKs, that should forward them to the backend.

Distributed tracing will work between DD-instrumented services and OTel-instrumented services, downstream OTel services will be able to forward the th field it to the collector and backend, which will calculate metrics correctly

Locally passes DataDog/system-tests#7518

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@vpellan
vpellan requested review from a team as code owners September 9, 2026 14:51
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 68.26% (-0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 927f2b8 | Docs | View more details | Give us feedback!

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-09T15:05:34.839614Z f7329a3 PR opened
🔒 Security Review ✅ Completed 2026-09-09T15:01:51.128033Z f7329a3 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f7329a3d7e

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

Comment thread tracer/otel_sampling.c Outdated
Comment thread tracer/otel_sampling.c Outdated
Comment thread tracer/distributed_tracing_headers.c Outdated
Comment thread tracer/priority_sampling/priority_sampling.c Outdated
@github-actions

Copy link
Copy Markdown
Contributor

Snapshots difference summary

The following differences have been observed in committed snapshots. It is meant to help the reviewer.
The diff is simplistic, so please check some files anyway while we improve it.

If you need to update snapshots, please refer to CONTRIBUTING.md

2 occurrences of :

- "_dd.span_links": "[{\"trace_id\":\"0000000000000000c151df7d6ee5e2d6\",\"span_id\":\"c151df7d6ee5e2d6\",\"trace_state\":\"dd=t.dm:-0\",\"attributes\":{\"_dd.p.dm\":\"-0\"}}]"
+ "_dd.span_links": "[{\"trace_id\":\"0000000000000000c151df7d6ee5e2d6\",\"span_id\":\"c151df7d6ee5e2d6\",\"trace_state\":\"dd=t.dm:-0,ot=rv:ea5f0f7db45435;th:0\",\"attributes\":{\"_dd.p.dm\":\"-0\"}}]"

Comment thread tracer/distributed_tracing_headers.c Outdated
Comment thread tracer/otel_sampling.c
Comment thread tracer/otel_sampling.c Outdated
@vpellan
vpellan force-pushed the vpellan/otel-threshold-random-value branch from 35dfbcb to 3f39364 Compare September 11, 2026 14:11
@pr-commenter

pr-commenter Bot commented Sep 14, 2026

Copy link
Copy Markdown

Benchmarks [ tracer ]

Benchmark execution time: 2026-09-14 19:15:08

Comparing candidate commit 38c7c80 in PR branch vpellan/otel-threshold-random-value with baseline commit c40e013 in branch master.

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

scenario:ContextPropagationBench/benchExtractHeaders128Bit

  • 🟥 execution_time [+53.067ns; +93.600ns] or [+6.199%; +10.935%]

scenario:ContextPropagationBench/benchExtractHeaders128Bit-opcache

  • 🟥 execution_time [+37.390ns; +103.943ns] or [+2.159%; +6.001%]

scenario:ContextPropagationBench/benchExtractHeaders64Bit-opcache

  • 🟥 execution_time [+41.820ns; +124.180ns] or [+3.468%; +10.297%]

scenario:ContextPropagationBench/benchExtractTraceContext128Bit

  • 🟥 execution_time [+43.401ns; +114.599ns] or [+2.338%; +6.174%]

scenario:ContextPropagationBench/benchExtractTraceContext64Bit

  • 🟥 execution_time [+60.018ns; +77.982ns] or [+7.094%; +9.218%]

scenario:ContextPropagationBench/benchExtractTraceContext64Bit-opcache

  • 🟥 execution_time [+61.646ns; +80.354ns] or [+7.287%; +9.498%]

scenario:SamplingRuleMatchingBench/benchRegexMatching1

  • 🟥 execution_time [+55.872ns; +118.728ns] or [+3.626%; +7.706%]

scenario:SamplingRuleMatchingBench/benchRegexMatching2

  • 🟥 execution_time [+43.056ns; +86.744ns] or [+2.771%; +5.582%]

scenario:SpanBench/benchOpenTelemetryAPI

  • 🟥 execution_time [+18.321µs; +31.697µs] or [+2.178%; +3.768%]
  • 🟥 mem_peak [+4.343MB; +4.343MB] or [+8.309%; +8.309%]

scenario:SpanBench/benchOpenTelemetryAPI-opcache

  • 🟥 mem_peak [+4.341MB; +4.341MB] or [+8.821%; +8.821%]

scenario:SpanBench/benchOpenTelemetryInteroperability

  • 🟥 execution_time [+11.371µs; +15.973µs] or [+5.211%; +7.320%]
  • 🟥 mem_peak [+1.076MB; +1.076MB] or [+3.649%; +3.649%]

scenario:SpanBench/benchOpenTelemetryInteroperability-opcache

  • 🟥 mem_peak [+1.074MB; +1.074MB] or [+4.072%; +4.072%]

@vpellan vpellan added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Sep 18, 2026
Pack 56-bit values and their lengths into two words, share optional unknown fields, and release them across extraction, inheritance, fork, and shutdown. Group root flags so root spans remain in the original allocator size class.
Comment thread tracer/otel_sampling.h Outdated
Comment thread tracer/otel_sampling.c Outdated
Comment thread tracer/otel_sampling.c Outdated
Comment thread tracer/otel_sampling.c Outdated
Comment thread tracer/otel_sampling.c
vpellan and others added 7 commits September 28, 2026 14:46
PHP 7.0 interprets void as a class return type, causing report() to throw when it returns without a value. Keep the helper untyped without changing the caps assertions.
The Valgrind LEAK label is caused by PCRE JIT vectorized reads in report(), not leaked sampling-state storage. Parse the ot member and foo field directly while preserving the ownership scenarios and expected output.

Verified the original test reports LEAK and the replacement passes under PHP 8.3 ARM64 Valgrind with the same temporary suppression for an unrelated local Rust startup warning. No project suppressions changed. Normal regression suite: 57 passed, one skipped.

@bwoebi bwoebi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me now, thanks!

@vpellan
vpellan merged commit b0e87b0 into master Sep 30, 2026
2197 checks passed
@vpellan
vpellan deleted the vpellan/otel-threshold-random-value branch September 30, 2026 13:06
@github-actions github-actions Bot added this to the 1.26.0 milestone Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants