Skip to content

feat(undici): emit data streams checkpoints for native undici requests - #11212

Open
johannbotha wants to merge 7 commits into
masterfrom
jj/dsm-node-http-fetch
Open

johannbotha wants to merge 7 commits into
masterfrom
jj/dsm-node-http-fetch

Conversation

@johannbotha

@johannbotha johannbotha commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds HTTP Data Streams Monitoring checkpoints to native undici requests: undici.request, undici.fetch, Pool and Client. They share the http client's helper and behave the same way: AWS SDK requests are skipped, a forwarded pathway header is replaced, and DD_DATA_STREAMS_HTTP_ENABLED turns them off. Global fetch still records a single checkpoint, through the http client plugin.

Builds on #11211 (merged).

Motivation

Without this change, services that call other services through undici directly break their pathways at that hop.

Additional Notes

Native undici requests have no store of their own, so their context travels only in the outgoing header. The legacy undici.fetch wrapper (4.4 to 5.0) now replaces a forwarded pathway header too. In the history, each test commit fails before its feature commit lands.

🤖 Generated with Claude Code

@linear-code

linear-code Bot commented Nov 12, 2026

Copy link
Copy Markdown

DSM2-665

@dd-octo-sts

dd-octo-sts Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 9.56 MB
Deduped: 10.31 MB
No deduping: 10.31 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.5.3 | 131.25 kB | 531.9 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-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 98.57% (+0.01%)

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

@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.15%. Comparing base (2b9eb2f) to head (efbcfd6).
⚠️ Report is 25 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #11212    +/-   ##
========================================
  Coverage   99.15%   99.15%            
========================================
  Files        1128     1136     +8     
  Lines      187432   188415   +983     
  Branches       82       86     +4     
========================================
+ Hits       185843   186831   +988     
+ Misses       1588     1584     -4     
+ Partials        1        0     -1     
Flag Coverage Δ
ai-guard 63.33% <0.00%> (+0.07%) ⬆️
apm-capabilities 55.16% <22.72%> (-0.04%) ⬇️
apm-integrations 81.96% <100.00%> (+0.19%) ⬆️
appsec 59.24% <33.33%> (+0.14%) ⬆️
debugger 70.89% <0.00%> (+0.05%) ⬆️
instrumentation 60.17% <33.33%> (+0.16%) ⬆️
llmobs 82.51% <33.33%> (+0.04%) ⬆️
master-coverage 99.15% <100.00%> (?)
openfeature 68.07% <0.00%> (+0.07%) ⬆️
platform 68.15% <0.00%> (+0.10%) ⬆️
profiling 66.51% <0.00%> (+0.09%) ⬆️
serverless 66.64% <31.91%> (+0.34%) ⬆️
test-optimization 82.00% <36.36%> (+0.02%) ⬆️

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.

@pr-commenter

pr-commenter Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-11-23 21:38:05

Comparing candidate commit efbcfd6 in PR branch jj/dsm-node-http-fetch with baseline commit 2b9eb2f in branch master.

📊 Benchmarking dashboard

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

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

  • unstable max_rss_usage [-64.929MB; +53.095MB] or [-29.965%; +24.503%]

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

  • unstable max_rss_usage [-19.979MB; +38.222MB] or [-7.312%; +13.988%]

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

  • unstable max_rss_usage [-33.003MB; +24.192MB] or [-9.140%; +6.700%]

scenario:appsec-iast-with-vulnerability-iast-enabled-default-config-26

  • unstable max_rss_usage [-27528.495KB; +28300.495KB] or [-9.101%; +9.356%]

scenario:debugger-line-probe-with-snapshot-default-20

  • unstable max_rss_usage [-4.936MB; +10.167MB] or [-3.633%; +7.484%]

scenario:openfeature-initialization-configuration-20

  • unstable max_rss_usage [-5194.787KB; +4425.332KB] or [-6.824%; +5.813%]

scenario:openfeature-initialization-configuration-26

  • unstable cpu_user_time [-115.025ms; +104.381ms] or [-6.683%; +6.064%]
  • unstable execution_time [-116.071ms; +103.850ms] or [-6.492%; +5.808%]
  • unstable throughput [-30790.173op/s; +35718.878op/s] or [-5.413%; +6.279%]

scenario:openfeature-scale-full-26

  • unstable max_rss_usage [-25.122MB; +32.033MB] or [-11.109%; +14.165%]

scenario:plugin-graphql-long-with-depth-off-26

  • unstable max_rss_usage [-20.090MB; +31.973MB] or [-10.673%; +16.986%]

scenario:propagation-extract-baggage-percent-26

  • unstable cpu_user_time [-88.941ms; +151.273ms] or [-4.804%; +8.170%]
  • unstable execution_time [-93.218ms; +155.313ms] or [-4.944%; +8.237%]
  • unstable throughput [-10661.583op/s; +6343.104op/s] or [-6.638%; +3.949%]

@johannbotha
johannbotha force-pushed the jj/dsm-node-http-fetch branch from f47f837 to 890b28f Compare November 13, 2026 04:30
@johannbotha
johannbotha force-pushed the jj/dsm-node-http-core branch from 9bae622 to 29355b1 Compare November 13, 2026 15:41
@johannbotha
johannbotha force-pushed the jj/dsm-node-http-fetch branch 3 times, most recently from ab17f0c to c1f9b48 Compare November 13, 2026 21:29
@johannbotha
johannbotha force-pushed the jj/dsm-node-http-core branch from 503f5e3 to 24cdc71 Compare November 13, 2026 22:06
@johannbotha
johannbotha force-pushed the jj/dsm-node-http-fetch branch 2 times, most recently from 01f053d to 1afbbcf Compare November 14, 2026 23:33
@johannbotha
johannbotha force-pushed the jj/dsm-node-http-fetch branch from 1afbbcf to 8be7e49 Compare November 15, 2026 00:03
@johannbotha johannbotha reopened this Nov 15, 2026
@johannbotha
johannbotha force-pushed the jj/dsm-node-http-fetch branch 3 times, most recently from 6f10354 to aaeac8e Compare November 19, 2026 19:04
Base automatically changed from jj/dsm-node-http-core to master November 20, 2026 18:04
johannbotha and others added 6 commits November 20, 2026 13:11
…ests

Specifies one direction:out,type:http checkpoint per request for
undici.request, undici.fetch, Pool, Client and global fetch with the
fetch plugin off, with the pathway hashes that dd-trace-java's hashing
classes compute for the same chain with process tags off: chaining from
a server checkpoint in a handler, per-hop edge latency, a forwarded
pathway header being replaced, and no checkpoint or pathway header for
AWS SDK requests, blocklisted URLs, or when DSM or
DD_DATA_STREAMS_HTTP_ENABLED is off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Requests traced through undici's native diagnostics channels (undici
>=4.7.0: undici.request, fetch, Pool, Client, and global fetch when the
fetch plugin is off) record the same direction:out,type:http checkpoint
as the http client and inject dd-pathway-ctx-base64, replacing one the
caller forwards. They follow the http client's rules: gated on
DD_DATA_STREAMS_ENABLED, DD_DATA_STREAMS_HTTP_ENABLED and the
blocklist, and skipped for AWS SDK requests. Native requests have no
store of their own, so the context only travels in the header. Global
fetch keeps its single checkpoint from the fetch plugin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…header

On every undici version, including the legacy fetch wrapper used for
undici 4.4.1-4.6.x and 5.0.x, a dd-pathway-ctx-base64 header the caller
forwards must be replaced by the request's own pathway context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rapper

undici.fetch on undici 4.4.1-4.6.x and 5.0.x goes through the legacy
wrapper, which only copied headers the request did not already have, so
a caller's dd-pathway-ctx-base64 reached downstream instead of the
request's own. It now overwrites the header, as the http, fetch and
native undici paths do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rvers

Before Node.js 19, server.close() waits for open connections, which
fetch and undici keep alive, so the DSM spec's teardown timed out on
Node.js 18.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@johannbotha
johannbotha force-pushed the jj/dsm-node-http-fetch branch from aaeac8e to 15ee16c Compare November 20, 2026 18:12
@johannbotha
johannbotha marked this pull request as ready for review November 20, 2026 18:12
@johannbotha
johannbotha requested a review from a team as a code owner November 20, 2026 18:12
@johannbotha
johannbotha requested a review from a team as a code owner November 20, 2026 18:12
@johannbotha
johannbotha requested review from tlhunter and removed request for a team November 20, 2026 18:12
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T21:21:44.720951Z efbcfd6 New commits
🔒 Security Review ✅ Completed 2026-11-23T21:23:52.505860Z efbcfd6 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.

this.config.dsmEnabled &&
this.config.DD_DATA_STREAMS_HTTP_ENABLED &&
allowed &&
!isAwsSdkRequest(store?.span, normalizeHeaders(request.headers)['amz-sdk-invocation-id'])

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.

It would be unfortunate to let specific Amazon concepts leak into the Undici plugin. How about this file calls a helper method so that it doesn't need to contain the Amazon header?

 !isAwsSdkRequestFoo(store?.span, normalizeHeaders(request.headers))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call, thanks. isAwsSdkRequest now takes the headers and owns the AWS header name, so neither the undici nor the http client plugin mentions it any more. Undici still normalizes first, since its raw headers are a string or array depending on version.

isAwsSdkRequest now takes the outgoing headers, so the http and undici
plugins no longer reference amz-sdk-invocation-id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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