Skip to content

fix(opentelemetry): Strip leading ? and # from inferred http.query and http.fragment - #21848

Merged
andreiborza merged 1 commit into
developfrom
ab/strip-http-query-fragment
Jun 29, 2026
Merged

fix(opentelemetry): Strip leading ? and # from inferred http.query and http.fragment#21848
andreiborza merged 1 commit into
developfrom
ab/strip-http-query-fragment

Conversation

@andreiborza

Copy link
Copy Markdown
Member

What

Strip the leading ?/# from the inferred http.query and http.fragment span attributes in descriptionForHttpMethod.

Why

The inferred values were taken straight from URL.search/URL.hash, which include the leading ?/#. The OTel SDK span exporter (getData in spanExporter.ts) slices these off, so the same logical attribute ended up in two different formats depending on the code path. Stripping the prefix here makes both paths emit the same canonical format.

…d http.fragment
The inferred `http.query` and `http.fragment` span attributes kept the leading
`?`/`#` from `URL.search`/`URL.hash`, unlike the values the OTel SDK span exporter
emits (`getData` in `spanExporter.ts` slices these off). Strip them so both code
paths produce the same canonical attribute format.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@andreiborza
andreiborza requested a review from a team as a code ownerJune 29, 2026 14:23
@andreiborza
andreiborza requested review from JPeer264 and mydea and removed request for a teamJune 29, 2026 14:23
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser27.48 kB--
@sentry/browser - with treeshaking flags25.91 kB--
@sentry/browser (incl. Tracing)46.01 kB--
@sentry/browser (incl. Tracing + Span Streaming)47.76 kB--
@sentry/browser (incl. Tracing, Profiling)50.8 kB--
@sentry/browser (incl. Tracing, Replay)85.26 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags74.85 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)89.95 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)102.61 kB--
@sentry/browser (incl. Feedback)44.66 kB--
@sentry/browser (incl. sendFeedback)32.26 kB--
@sentry/browser (incl. FeedbackAsync)37.4 kB--
@sentry/browser (incl. Metrics)28.54 kB--
@sentry/browser (incl. Logs)28.78 kB--
@sentry/browser (incl. Metrics & Logs)29.47 kB--
@sentry/react29.27 kB--
@sentry/react (incl. Tracing)48.32 kB--
@sentry/vue32.66 kB--
@sentry/vue (incl. Tracing)47.87 kB--
@sentry/svelte27.5 kB--
CDN Bundle29.89 kB--
CDN Bundle (incl. Tracing)47.95 kB--
CDN Bundle (incl. Logs, Metrics)31.44 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)49.3 kB--
CDN Bundle (incl. Replay, Logs, Metrics)70.77 kB--
CDN Bundle (incl. Tracing, Replay)85.45 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)86.72 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)91.25 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)92.5 kB--
CDN Bundle - uncompressed88.95 kB--
CDN Bundle (incl. Tracing) - uncompressed145.18 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed93.65 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed149.15 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed218.63 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed264.19 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed268.15 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed277.89 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed281.84 kB--
@sentry/nextjs (client)50.71 kB--
@sentry/sveltekit (client)46.41 kB--
@sentry/core/server77.67 kB--
@sentry/core/browser63.97 kB--
@sentry/node-core61.42 kB+0.02%+8 B 🔺
@sentry/node122.66 kB+0.01%+5 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection)69.95 kB--
@sentry/node/light50.39 kB--
@sentry/node - without tracing73.14 kB+0.01%+5 B 🔺
@sentry/aws-serverless84.02 kB+0.01%+4 B 🔺
@sentry/cloudflare (withSentry) - minified180.46 kB--
@sentry/cloudflare (withSentry)446.48 kB--

View base workflow run

@andreiborza
andreiborza merged commit 3f16a32 into developJun 29, 2026
436 of 439 checks passed
@andreiborza
andreiborza deleted the ab/strip-http-query-fragment branch June 29, 2026 15:43
@mjq

mjq commented Jun 29, 2026

Copy link
Copy Markdown
Member

@andreiborza@Lms24 Just an FYI here that our conventions specify that this property contains a leading ?, so by our own specs this appears to be backwards and we ought to have changed the OTel span exporter to stop stripping the leading ? instead.

That said the ideal option is probably to deprecate http.query entirely and start using url.query instead (which we also have conventions for, does not include the leading ?, and, unlike http.query, exists in OTel's conventions too). I don't know why the leading ? would be useful to a telemetry consumer 🤷

@andreiborza

andreiborza commented Jun 29, 2026

Copy link
Copy Markdown
MemberAuthor

@mjq thanks for raising this! I aligned this with our current span exporter, we can go for url.query in v11 but I'd rather not break existing users now.

andreiborza added a commit that referenced this pull request Jun 30, 2026
…ation (#21852)
Adds `TODO(v11)` markers at the two spots that strip the leading `?`/`#`
from `http.query`/`http.fragment` — the span exporter's `getData` and
`parseSpanDescription`'s `descriptionForHttpMethod`.
Per the [discussion on
#21848](#21848 (comment)),
`http.query` is specced to *keep* the leading `?`, so the stripping
diverges from our own conventions. The v11 direction is to emit the
OTel-standard `url.query`/`url.fragment` (no leading char, already in
`@sentry/conventions`) and drop `http.query`/`http.fragment`.
Comment-only, no behavior change.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for freeto 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.

4 participants

@andreiborza@mjq@Lms24@JPeer264