Skip to content

feat(browser): Emit low cardinality navigation span names - #23550

Merged
logaretm merged 2 commits into
developfrom
awad/js-3407-emit-low-cardinality-navigation-span-names
Aug 27, 2026
Merged

feat(browser): Emit low cardinality navigation span names#23550
logaretm merged 2 commits into
developfrom
awad/js-3407-emit-low-cardinality-navigation-span-names

Conversation

@logaretm

@logaretm logaretm commented Aug 24, 2026

Copy link
Copy Markdown
Member

Names navigation spans Navigation when span streaming is enabled and the SDK has no parameterized route for them. Names in static mode are unchanged.

The scope's transaction name keeps the URL, since that's what error events group by. navigation.redirect spans share the code path so they get the fallback too, which imo is right.

closes #23522

@linear-code

linear-code Bot commented Aug 24, 2026

Copy link
Copy Markdown

JS-3407

@logaretm
logaretm force-pushed the awad/js-3407-emit-low-cardinality-navigation-span-names branch from 6eeaeb1 to 97991d2 Compare August 24, 2026 18:47
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

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.61 kB +0.07% +30 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 48.63 kB +0.06% +29 B 🔺
@sentry/browser (incl. Tracing, Profiling) 51.54 kB +0.06% +27 B 🔺
@sentry/browser (incl. Tracing, Replay) 88.1 kB +0.04% +33 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.48 kB +0.03% +21 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 92.8 kB +0.05% +39 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 105.48 kB +0.04% +35 B 🔺
@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.82 kB +0.05% +23 B 🔺
@sentry/vue 35.69 kB - -
@sentry/vue (incl. Tracing) 50.86 kB +0.09% +45 B 🔺
@sentry/svelte 28.59 kB - -
CDN Bundle 30.36 kB - -
CDN Bundle (incl. Tracing) 49.09 kB +0.06% +29 B 🔺
CDN Bundle (incl. Logs, Metrics) 32.56 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.98 kB +0.06% +28 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 73 kB - -
CDN Bundle (incl. Tracing, Replay) 86.6 kB +0.03% +25 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.5 kB +0.05% +40 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 92.38 kB +0.04% +30 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.3 kB +0.03% +27 B 🔺
CDN Bundle - uncompressed 89.97 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.77 kB +0.06% +83 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.26 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.46 kB +0.06% +83 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.42 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.27 kB +0.04% +83 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.94 kB +0.04% +83 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.96 kB +0.03% +83 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.62 kB +0.03% +83 B 🔺
@sentry/nextjs (client) 53.39 kB +0.11% +55 B 🔺
@sentry/sveltekit (client) 49.05 kB +0.06% +29 B 🔺
@sentry/core/server 65.3 kB - -
@sentry/core/browser 52.35 kB - -
@sentry/node 122.72 kB +0.02% +20 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.22 kB - -
@sentry/node - without tracing 87.97 kB +0.03% +21 B 🔺
@sentry/aws-serverless 96.19 kB +0.03% +22 B 🔺
@sentry/cloudflare (withSentry) - minified 199.57 kB - -
@sentry/cloudflare (withSentry) 495.71 kB - -

View base workflow run

@logaretm
logaretm marked this pull request as ready for review August 24, 2026 19:38
@logaretm
logaretm requested review from a team as code owners August 24, 2026 19:38
@logaretm
logaretm requested review from Lms24, chargome, msonnb and nicohrubec and removed request for a team August 24, 2026 19:38
Comment thread packages/solid/src/solidrouter.ts
span.updateName(pathname);
// With span streaming, span names have to be low cardinality, so we can't fall back to the URL.
const client = getClient();
span.updateName(client && hasSpanStreamingEnabled(client) ? NAVIGATION_SPAN_NAME_FALLBACK : pathname);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoidable getClient in utils

Low Severity

This is more an “is this necessary” check than a hard violation: updateNavigationSpanUrlFromLocation newly calls getClient() to gate the streaming name. Callers already have or can receive a client, so threading it through would avoid creating/relying on a current client in multi-client setups.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 97991d2. Configure here.

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.

probably a false flag

@Lms24 Lms24 left a comment

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.

Nice, thank you! Clanker comments are probably false positives but worth double checking.

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.

no action required, just comment: Angular is a pretty bad offender in terms of getting early route parameterization :( Maybe something to revisit some day, though their closed approach to the build system (by default) probably makes a manifest injection like in other frameworks less practical.

Not pretty but I think this is the best we can do here.

span.updateName(pathname);
// With span streaming, span names have to be low cardinality, so we can't fall back to the URL.
const client = getClient();
span.updateName(client && hasSpanStreamingEnabled(client) ? NAVIGATION_SPAN_NAME_FALLBACK : pathname);

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.

probably a false flag

Comment thread packages/solid/src/solidrouter.ts
Names navigation spans `Navigation` when span streaming is enabled and the SDK has no parameterized route for them. Names in static mode are unchanged.
@logaretm
logaretm force-pushed the awad/js-3407-emit-low-cardinality-navigation-span-names branch from 97991d2 to ec31f77 Compare August 26, 2026 20:20
Comment thread packages/react-router/src/client/utils.ts

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ec31f77. Configure here.

Comment thread packages/react-router/src/client/utils.ts
name:
source === 'route' || !hasSpanStreamingEnabled(client)
? placeholderEntry.routeName
: NAVIGATION_SPAN_NAME_FALLBACK,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Scope transaction name drops router path

Medium Severity

Several React/Remix navigation starts now pass the Navigation fallback but omit the url option. startBrowserTracingNavigationSpan then sets scope.transactionName from WINDOW.location.pathname, which is the previous page during some transitions and the document path (/) for hash/memory routers, so errors group away from the actual route.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ec31f77. Configure here.

… route chain

`getParameterizedRoute` only looked at the leaf match and fell back to the raw
`location.pathname` when it had no `route.path`. Index and layout routes have
none, so a library-mode navigation to `/users/123` under an index child was named
`/users/123` with `sentry.segment.name.source: 'route'`, putting a raw URL back
into a streamed span name. Nested children were also mis-named after their own
relative segment (`/edit` instead of `/users/:id/edit`).

Joining the matched chain resolves both. Framework-mode route configs are
unaffected: `prefix()` flattens the full path onto each child, so the joined
template equals the leaf path it produced before. When nothing matches at all,
streamed spans now keep their `Navigation`/`Pageload` name instead of taking the
URL; static-lifecycle names are unchanged.
@logaretm
logaretm enabled auto-merge (squash) August 27, 2026 01:50
@logaretm
logaretm merged commit 3ec962c into develop Aug 27, 2026
208 checks passed
@logaretm
logaretm deleted the awad/js-3407-emit-low-cardinality-navigation-span-names branch August 27, 2026 02:01
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.

Emit low cardinality navigation span names

2 participants