Skip to content

feat: Emit low-cardinality http.client span names for node:http and undici - #23690

Open
chargome wants to merge 2 commits into
developfrom
charlygomez/js-3412-http-client-node
Open

feat: Emit low-cardinality http.client span names for node:http and undici#23690
chargome wants to merge 2 commits into
developfrom
charlygomez/js-3412-http-client-node

Conversation

@chargome

Copy link
Copy Markdown
Member

With span streaming, http.client spans are named {method} {url.domain} (GET api.example.com)
instead of {method} {sanitized-url}, falling back to the method alone when there is no domain.
traceLifecycle: 'static' is unchanged.

Covers outgoing node:http/https requests, undici (global fetch), and
googleCloudHttpIntegration. The fetch and XHR side is #23682, which also carries the
migration note for both.

Spans also get a url.domain attribute in both lifecycles, so the value in the name stays
filterable — same as the resource.* port.

Ref #23527

…ndici

With span streaming, `http.client` spans are named `{method} {url.domain}` instead of
`{method} {sanitized-url}`, falling back to the method alone when there is no domain.
Covers outgoing `node:http`/`https` requests, undici, and `googleCloudHttpIntegration`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@chargome chargome self-assigned this Aug 27, 2026
@linear-code

linear-code Bot commented Aug 27, 2026

Copy link
Copy Markdown

JS-3412

@chargome

Copy link
Copy Markdown
Member Author

bugbot run

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 28.57 kB - -
@sentry/browser - with treeshaking flags 26.92 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB - -
@sentry/browser (incl. Tracing) 48.63 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.65 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.56 kB - -
@sentry/browser (incl. Tracing, Replay) 88.11 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.51 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.82 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.51 kB - -
@sentry/browser (incl. Feedback) 45.79 kB - -
@sentry/browser (incl. sendFeedback) 33.35 kB - -
@sentry/browser (incl. FeedbackAsync) 38.46 kB - -
@sentry/browser (incl. Metrics) 29.51 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.43 kB - -
@sentry/react 30.31 kB - -
@sentry/react (incl. Tracing) 50.84 kB - -
@sentry/vue 35.69 kB - -
@sentry/vue (incl. Tracing) 50.88 kB - -
@sentry/svelte 28.59 kB - -
CDN Bundle 30.36 kB - -
CDN Bundle (incl. Tracing) 49.12 kB - -
CDN Bundle (incl. Logs, Metrics) 32.56 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.01 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73 kB - -
CDN Bundle (incl. Tracing, Replay) 86.62 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.52 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.4 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.33 kB - -
CDN Bundle - uncompressed 89.97 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.82 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.26 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.51 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.42 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.32 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.01 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.68 kB - -
@sentry/nextjs (client) 53.41 kB - -
@sentry/sveltekit (client) 49.08 kB - -
@sentry/core/server 65.2 kB -0.17% -107 B 🔽
@sentry/core/browser 52.37 kB - -
@sentry/node 122.77 kB +0.25% +296 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.22 kB - -
@sentry/node - without tracing 87.84 kB +0.24% +202 B 🔺
@sentry/node - without channel injection 102.46 kB +0.29% +294 B 🔺
@sentry/aws-serverless 95.99 kB +0.21% +197 B 🔺
@sentry/cloudflare (withSentry) - minified 199.61 kB - -
@sentry/cloudflare (withSentry) 495.94 kB - -

View base workflow run

The outgoing request span now carries `url.domain`, and the assertion compares `data` exactly.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@chargome

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor 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.

✅ Bugbot reviewed your changes and found no new issues!

1 issue from previous review remains unresolved.

Fix All in Cursor

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 1c6aa69. Configure here.

@chargome
chargome marked this pull request as ready for review August 27, 2026 16:13
@chargome
chargome requested review from a team as code owners August 27, 2026 16:13
@chargome
chargome requested review from JPeer264 and isaacs and removed request for a team August 27, 2026 16:13
Comment on lines 222 to 228
[HTTP_REQUEST_METHOD]: requestMethod,
[ATTR_HTTP_REQUEST_METHOD_ORIGINAL]: request.method,
[URL_FULL]: filterCollectedUrl(requestUrl.toString()),
[URL_DOMAIN]: requestUrl.hostname || undefined,
[URL_PATH]: requestUrl.pathname,
[URL_QUERY]: filterCollectedUrlQuery(getUrlQuery(requestUrl.search)),
[URL_FRAGMENT]: getUrlFragment(requestUrl.hash),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The streaming path for undici/fetch does not strip the internal SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME attribute for data: URLs, leading to a potential high-cardinality transaction name in Sentry.
Severity: LOW

Suggested Fix

Before serializing the span for streaming, delete the SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME attribute from the span's attributes. This would mirror the cleanup logic already present in the static (non-streaming) path's SentrySpan._convertSpanToTransaction() function.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/node/src/integrations/node-fetch/undici-instrumentation.ts#L222-L228

Potential issue: When span streaming is enabled for `undici`/`fetch` and a `data:` URL
is used, the internal attribute `SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME` is not
removed from the streamed span's attributes. The static (non-streaming) path correctly
deletes this attribute before sending the transaction, but the streaming path does not.
This inconsistency causes the attribute to be leaked, which can result in the Sentry
backend using a high-cardinality name for the transaction instead of the intended
low-cardinality one.

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant