Skip to content

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

Merged
vpellan merged 72 commits into
masterfrom
vpellan/otel-threshold-random-value
Oct 1, 2026
Merged

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

Conversation

@vpellan

@vpellan vpellan commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

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.

Motivation

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

Additional Notes

Locally passes DataDog/system-tests#7518

@vpellan
vpellan requested review from a team as code owners September 2, 2026 14:21
@vpellan
vpellan requested a review from BridgeAR September 2, 2026 14:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 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-10-01T08:23:35.864948Z 5911351 New commits
🔒 Security Review ✅ Completed 2026-10-01T08:24:34.058090Z 5911351 New commits
ℹ️ 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.

@dd-octo-sts

dd-octo-sts Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 9.33 MB
Deduped: 10.06 MB
No deduping: 10.06 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.5.1 | 127.66 kB | 513.61 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Tests

✅ All CI checks and tests passed. Datadog automation helped this PR pass.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog retried 1 test - 1 passed on retry View in Datadog

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 98.26% (+15.99%)

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

@vpellan
vpellan requested a review from a team as a code owner September 2, 2026 14:25

@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: 49eb6259f6

ℹ️ 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 packages/dd-trace/src/opentracing/propagation/text_map.js Outdated
Comment thread packages/dd-trace/src/priority_sampler.js Outdated
Comment thread packages/dd-trace/src/opentracing/propagation/text_map.js Outdated
Comment thread packages/dd-trace/src/opentracing/propagation/text_map.js Outdated
@pr-commenter

pr-commenter Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-10-01 09:02:17

Comparing candidate commit 2194615 in PR branch vpellan/otel-threshold-random-value with baseline commit 1d40b5f in branch master.

📊 Benchmarking dashboard

Found 12 performance improvements and 0 performance regressions! Performance is the same for 2309 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 ----------------------------------'

scenario:propagation-inject-replacements-20

  • 🟩 cpu_user_time [-1186.126ms; -439.795ms] or [-9.791%; -3.630%]
  • 🟩 execution_time [-1185.949ms; -439.516ms] or [-9.779%; -3.624%]
  • 🟩 instructions [-10.0G instructions; -3.8G instructions] or [-9.900%; -3.751%]
  • 🟩 throughput [+4492.157op/s; +12194.253op/s] or [+3.612%; +9.806%]

scenario:propagation-inject-replacements-24

  • 🟩 cpu_user_time [-1082.502ms; -404.527ms] or [-9.322%; -3.484%]
  • 🟩 execution_time [-1098.178ms; -408.779ms] or [-9.438%; -3.513%]
  • 🟩 instructions [-9.4G instructions; -3.5G instructions] or [-9.586%; -3.636%]
  • 🟩 throughput [+4547.424op/s; +12253.838op/s] or [+3.509%; +9.455%]

scenario:propagation-inject-replacements-26

  • 🟩 cpu_user_time [-1180.673ms; -445.877ms] or [-11.026%; -4.164%]
  • 🟩 execution_time [-1191.513ms; -449.586ms] or [-11.029%; -4.161%]
  • 🟩 instructions [-11.0G instructions; -4.2G instructions] or [-11.374%; -4.316%]
  • 🟩 throughput [+5818.520op/s; +15446.656op/s] or [+4.162%; +11.048%]

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-appsec-enabled-24

  • unstable max_rss_usage [-11.170MB; +18.517MB] or [-3.998%; +6.628%]

scenario:appsec-iast-no-vulnerability-iast-enabled-default-config-20

  • unstable max_rss_usage [-11893.414KB; +10990.414KB] or [-5.220%; +4.823%]

scenario:debugger-line-probe-without-snapshot-24

  • unstable cpu_user_time [-1001.780ms; +1652.242ms] or [-11.173%; +18.427%]
  • unstable execution_time [-1014.983ms; +1636.540ms] or [-10.063%; +16.225%]
  • unstable throughput [-171.797op/s; +111.746op/s] or [-15.153%; +9.856%]

scenario:debugger-line-probe-without-snapshot-26

  • unstable cpu_user_time [-365.411ms; +512.159ms] or [-4.229%; +5.927%]

scenario:plugin-graphql-long-with-depth-on-max-26

  • unstable max_rss_usage [-36.446MB; +26.600MB] or [-14.128%; +10.311%]

scenario:plugin-pino-json-log-injection-24

  • unstable cpu_user_time [-158.321ms; +247.130ms] or [-5.496%; +8.579%]
  • unstable execution_time [-172.627ms; +237.604ms] or [-5.947%; +8.185%]
  • unstable throughput [-110593.556op/s; +82716.591op/s] or [-6.378%; +4.770%]

@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: 42005a60a5

ℹ️ 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 packages/dd-trace/src/opentelemetry/span_context.js Outdated
Comment thread packages/dd-trace/src/priority_sampler.js Outdated
Comment thread packages/dd-trace/src/opentracing/propagation/text_map.js Outdated
Comment thread packages/dd-trace/src/knuth-hash.js
# Conflicts:
#	.github/CODEOWNERS
#	packages/dd-trace/src/opentracing/propagation/text_map.js
#	packages/dd-trace/test/opentracing/propagation/text_map.spec.js

@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: 660cb44f39

ℹ️ 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 packages/dd-trace/src/otel-sampling.js Outdated
@codecov

codecov Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.84%. Comparing base (1d40b5f) to head (2194615).
⚠️ Report is 48 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #10117       +/-   ##
===========================================
+ Coverage   82.30%   98.84%   +16.54%     
===========================================
  Files        1036     1047       +11     
  Lines      161965   168795     +6830     
  Branches       74       74               
===========================================
+ Hits       133304   166852    +33548     
+ Misses      28661     1943    -26718     
Flag Coverage Δ
ai-guard 64.05% <53.14%> (+0.55%) ⬆️
apm-capabilities 54.93% <100.00%> (-8.25%) ⬇️
apm-integrations 81.33% <90.87%> (?)
appsec 57.99% <87.77%> (+<0.01%) ⬆️
debugger 69.79% <54.54%> (-0.12%) ⬇️
instrumentation 55.45% <83.00%> (+0.61%) ⬆️
llmobs 80.48% <82.96%> (+0.33%) ⬆️
master-coverage 98.84% <100.00%> (?)
openfeature 66.04% <61.18%> (+0.01%) ⬆️
platform 68.89% <77.10%> (+0.15%) ⬆️
profiling 66.32% <52.31%> (-0.06%) ⬇️
serverless 65.83% <81.21%> (+0.64%) ⬆️
test-optimization 82.14% <91.94%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@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 4, 2026
Comment thread packages/dd-trace/src/opentracing/span.js Outdated
Comment thread packages/dd-trace/src/opentracing/span.js Outdated
Comment thread packages/dd-trace/src/opentracing/span.js Outdated
The extract-datadog microbenchmark reproduced a 6.22% regression versus master (713.82 vs 672.04 ns/op). Avoiding general integer parsing for canonical single-digit mechanisms reduced it to 2.08% (691.80 vs 677.73 ns/op), below the requested 5% ceiling. Node 22.23.2, 11 alternating measured samples per revision, startup excluded.

Retain the existing parser for every other input. Cover digit boundaries, multi-digit mechanisms, and permissive or invalid fallback inputs.
@vpellan
vpellan force-pushed the vpellan/otel-threshold-random-value branch from a0d66c5 to 525dc3b Compare September 17, 2026 20:12

@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: 525dc3b269

ℹ️ 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 packages/dd-trace/src/otel-sampling.js
Comment thread packages/dd-trace/src/opentracing/span.js
@vpellan

vpellan commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 525dc3b269

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

vpellan and others added 2 commits September 21, 2026 11:54
…10473)

* fix(propagation): enforce tracestate limits and bound pruning work

Tracestate permits 32 vendor members, not 32 fields within each member.
Preserve unknown OTel fields when sampling updates exceed the 256-character
member limit, and remove optional Datadog fields before required fields.

Repeated optional-field classification makes overflow pruning quadratic.
On Node.js 22.23.2, full injection with LLMObs overflow falls from
2.36–2.39 microseconds to 2.09–2.13 microseconds across two fresh processes.

* fix(propagation): retain standalone trace source in tracestate

Standalone AppSec uses the propagated trace source to retain a keep decision downstream. When an optional tag overflows W3C tracestate, pruning that source resets the extracted sampling priority and can drop the security trace.

LLMObs application and session attribution must remain together. Pruning only one would change downstream grouping.
@BridgeAR
BridgeAR requested a review from a team as a code owner September 25, 2026 11:19

@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: 5ae63fe38a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/dd-trace/src/standalone/index.js Outdated
Comment thread packages/dd-trace/src/opentracing/propagation/text_map.js Outdated

@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: 103d532883

ℹ️ 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 packages/dd-trace/src/opentelemetry/tracer.js
@vpellan
vpellan force-pushed the vpellan/otel-threshold-random-value branch from 103d532 to ef1ddb9 Compare September 25, 2026 14:21

@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: b427c4e3fa

ℹ️ 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 packages/dd-trace/src/opentracing/span.js

@BridgeAR BridgeAR 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. Just left two nits

Comment thread packages/dd-trace/src/opentracing/propagation/text_map.js Outdated
Comment thread packages/dd-trace/src/otel-sampling.js Outdated
vpellan and others added 2 commits October 1, 2026 04:18
Co-authored-by: Ruben Bridgewater <ruben@bridgewater.de>
Restore the parseInt fallback changed to Number in 5911351. Preserve integer-prefix parsing and leave empty values without a mechanism while retaining the single-digit fast path. Extend the existing regression matrix for decimal, exponent, hex-like, and whitespace inputs.
@vpellan
vpellan merged commit 9929cb5 into master Oct 1, 2026
678 checks passed
@vpellan
vpellan deleted the vpellan/otel-threshold-random-value branch October 1, 2026 09:06
This was referenced Oct 2, 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 semver-minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants