Repository navigation
feat(undici): emit data streams checkpoints for native undici requests - #11212
johannbotha wants to merge 7 commits into
Conversation
Overall package sizeSelf size: 9.56 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 |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: efbcfd6 | Docs | View more details | Give us feedback! |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
BenchmarksBenchmark execution time: 2026-11-23 21:38:05 Comparing candidate commit efbcfd6 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2473 metrics, 14 unstable metrics.
|
f47f837 to
890b28f
Compare
9bae622 to
29355b1
Compare
ab17f0c to
c1f9b48
Compare
503f5e3 to
24cdc71
Compare
01f053d to
1afbbcf
Compare
1afbbcf to
8be7e49
Compare
6f10354 to
aaeac8e
Compare
…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>
aaeac8e to
15ee16c
Compare
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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']) |
There was a problem hiding this comment.
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))There was a problem hiding this comment.
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>
What does this PR do?
Adds HTTP Data Streams Monitoring checkpoints to native
undicirequests:undici.request,undici.fetch,PoolandClient. They share the http client's helper and behave the same way: AWS SDK requests are skipped, a forwarded pathway header is replaced, andDD_DATA_STREAMS_HTTP_ENABLEDturns them off. Globalfetchstill 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.fetchwrapper (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