fix(span-stats): derive socketPath from the agent URL#9042
Conversation
The span-stats writer hand-copied protocol/hostname/port into the request options and never passed the agent URL, so request() could not reach its unix-socket branch and left protocol set to 'unix:'. With a named-pipe or UDS agent URL, http.request then threw ERR_INVALID_PROTOCOL and every span stats payload was dropped. Passing `url` lets request() map a unix: URL onto options.socketPath, the same way the trace agent exporter already does.
Overall package sizeSelf size: 6.32 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.2.0 | 104.26 kB | 843.44 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 🔗 Commit SHA: 1023740 | Docs | Datadog PR Page | Give us feedback! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d5c2720784
ℹ️ 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".
BenchmarksBenchmark execution time: 2026-06-24 19:06:06 Comparing candidate commit 1023740 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 1953 metrics, 12 unstable metrics.
|
The CI-visibility and profiling exporters built request options from `url.pathname` directly, so a Windows named-pipe agent URL (`unix://./pipe/...`) lost its `//.` authority and the request hit the wrong socket path. parseUrl now lives in exporters/common/url.js and folds that authority back into the path, so all three request paths derive the socket path the same way and can no longer drift. Drive-by fix: * The common request spec restores its sinon sandbox instead of resetting it, so the `http.request` spy no longer leaks into sibling suites.
The agent-telemetry fallback passed the agentless intake endpoint to `request` as a string while the primary agentless path already constructed a `URL`. Build it with `new URL` up front and guard it the same way, so an invalid endpoint is logged and the request skipped rather than throwing from inside the request helper.
48ae52e to
9281ba3
Compare
The new url.js added here landed in src/exporters/common/, which had no code owner except the single retry.js rule, leaving it and eight sibling files unowned. Broadening the rule to the directory gives every current and future file there an owner.
* fix(span-stats): derive socketPath from the agent URL The span-stats writer hand-copied protocol/hostname/port into the request options and never passed the agent URL, so request() could not reach its unix-socket branch and left protocol set to 'unix:'. With a named-pipe or UDS agent URL, http.request then threw ERR_INVALID_PROTOCOL and every span stats payload was dropped. Passing `url` lets request() map a unix: URL onto options.socketPath, the same way the trace agent exporter already does. * fix(exporters): recompose named-pipe socket paths in one shared helper The CI-visibility and profiling exporters built request options from `url.pathname` directly, so a Windows named-pipe agent URL (`unix://./pipe/...`) lost its `//.` authority and the request hit the wrong socket path. parseUrl now lives in exporters/common/url.js and folds that authority back into the path, so all three request paths derive the socket path the same way and can no longer drift. Drive-by fix: * The common request spec restores its sinon sandbox instead of resetting it, so the `http.request` spy no longer leaks into sibling suites. * refactor(telemetry): send the agentless backend URL as a URL object The agent-telemetry fallback passed the agentless intake endpoint to `request` as a string while the primary agentless path already constructed a `URL`. Build it with `new URL` up front and guard it the same way, so an invalid endpoint is logged and the request skipped rather than throwing from inside the request helper.
* fix(span-stats): derive socketPath from the agent URL The span-stats writer hand-copied protocol/hostname/port into the request options and never passed the agent URL, so request() could not reach its unix-socket branch and left protocol set to 'unix:'. With a named-pipe or UDS agent URL, http.request then threw ERR_INVALID_PROTOCOL and every span stats payload was dropped. Passing `url` lets request() map a unix: URL onto options.socketPath, the same way the trace agent exporter already does. * fix(exporters): recompose named-pipe socket paths in one shared helper The CI-visibility and profiling exporters built request options from `url.pathname` directly, so a Windows named-pipe agent URL (`unix://./pipe/...`) lost its `//.` authority and the request hit the wrong socket path. parseUrl now lives in exporters/common/url.js and folds that authority back into the path, so all three request paths derive the socket path the same way and can no longer drift. Drive-by fix: * The common request spec restores its sinon sandbox instead of resetting it, so the `http.request` spy no longer leaks into sibling suites. * refactor(telemetry): send the agentless backend URL as a URL object The agent-telemetry fallback passed the agentless intake endpoint to `request` as a string while the primary agentless path already constructed a `URL`. Build it with `new URL` up front and guard it the same way, so an invalid endpoint is logged and the request skipped rather than throwing from inside the request helper.
Summary
The span-stats writer hand-copied
protocol/hostname/portinto the request options and never passed the agent URL, sorequest()could not reach its unix-socket branch and leftprotocol: 'unix:'in place. With a Windows named-pipe or UDS agent URL,http.requestthen threwERR_INVALID_PROTOCOLand every span-stats payload was dropped. Passingurlletsrequest()map aunix:URL ontooptions.socketPath, the same way the trace agent exporter already does.Test plan
packages/dd-trace/test/exporters/span-stats/writer.spec.js— new case asserts the writer handsurlthrough and does not pre-setprotocol; fails onmaster, passes with the fix.request.spec.jsalready covers theunix:URL ->socketPathmapping.