Skip to content

feat(core): Emit low cardinality router span names - #23547

Open
logaretm wants to merge 1 commit into
developfrom
awad/js-3417-emit-low-cardinality-router-span-names
Open

feat(core): Emit low cardinality router span names#23547
logaretm wants to merge 1 commit into
developfrom
awad/js-3417-emit-low-cardinality-router-span-names

Conversation

@logaretm

Copy link
Copy Markdown
Member

Names router spans after the route they dispatch when span streaming is enabled, else Router. Static mode is unchanged.

SDK Before After
Express (OTel) /c mount path http.route
Express (orchestrion) /users/123 http.route
Koa /users/:id same, Router if pathless
Hapi GET /users/{id} /users/{id}
Angular /users/123 Router
Ember route:a -> route:b Router
SvelteKit SvelteKit Route Change Router

Only Koa already used its http.route. Hapi drops the method since the template has none; Angular, Ember and SvelteKit carry no route.

closes #23532

@linear-code

linear-code Bot commented Aug 24, 2026

Copy link
Copy Markdown

JS-3417

@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.34 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.36 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.25 kB - -
@sentry/browser (incl. Tracing, Replay) 87.74 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.2 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.45 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.13 kB - -
@sentry/browser (incl. Feedback) 45.81 kB - -
@sentry/browser (incl. sendFeedback) 33.36 kB - -
@sentry/browser (incl. FeedbackAsync) 38.47 kB - -
@sentry/browser (incl. Metrics) 29.52 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.45 kB - -
@sentry/react 30.33 kB - -
@sentry/react (incl. Tracing) 50.52 kB - -
@sentry/vue 35.4 kB - -
@sentry/vue (incl. Tracing) 50.32 kB - -
@sentry/svelte 28.6 kB - -
CDN Bundle 30.32 kB - -
CDN Bundle (incl. Tracing) 48.87 kB - -
CDN Bundle (incl. Logs, Metrics) 32.54 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.74 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 72.91 kB - -
CDN Bundle (incl. Tracing, Replay) 86.33 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.16 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.07 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94 kB - -
CDN Bundle - uncompressed 89.94 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.13 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.23 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 151.81 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.18 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.4 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.07 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.09 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 284.76 kB - -
@sentry/nextjs (client) 53.06 kB - -
@sentry/sveltekit (client) 48.76 kB +0.02% +7 B 🔺
@sentry/core/server 64.97 kB +0.04% +20 B 🔺
@sentry/core/browser 52.11 kB - -
@sentry/node 117.55 kB +0.07% +82 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.18 kB - -
@sentry/node - without tracing 82.03 kB +0.03% +24 B 🔺
@sentry/aws-serverless 91.46 kB +0.03% +22 B 🔺
@sentry/cloudflare (withSentry) - minified 194.68 kB - -
@sentry/cloudflare (withSentry) 481.3 kB - -

View base workflow run

@logaretm
logaretm force-pushed the awad/js-3417-emit-low-cardinality-router-span-names branch 2 times, most recently from 5d83782 to 1318630 Compare August 24, 2026 18:38
Names `router` spans after the route they dispatch when span streaming is
enabled, falling back to `Router` when the SDK has no route, per
https://getsentry.github.io/sentry-conventions/names/#routing-router.

Covers all seven sites that emit the `router` op: the OTel-derived and
orchestrion Express integrations, Koa, Hapi, Angular, Ember and SvelteKit
(Svelte 4 and 5). Two of them were leaking high-cardinality values: the
orchestrion Express integration named router spans `layer.path`, which
Express assigns the *matched* URL segment (verified against express
4.22.1: `app.use('/users/:id', router)` yields `/users/123`), and Angular
named them the raw navigation URL, since the parameterized route only
resolves at `ResolveEnd` and is applied to the root span rather than to
the routing span.

Angular, Ember and SvelteKit have no route value at the span, so they take
the fallback. Hapi drops its `GET ` prefix because the convention's
template has no method component.

`traceLifecycle: 'static'` names are byte-identical; the existing static
integration and e2e assertions are the regression check.
@logaretm
logaretm force-pushed the awad/js-3417-emit-low-cardinality-router-span-names branch from 1318630 to be3a06a Compare August 24, 2026 18:44
@logaretm
logaretm marked this pull request as ready for review August 24, 2026 18:50
@logaretm
logaretm requested review from a team as code owners August 24, 2026 18:50
@logaretm
logaretm requested review from chargome and nicohrubec and removed request for a team August 24, 2026 18:50

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

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 be3a06a. Configure here.


const client = getClient();
// With span streaming, span names have to be low cardinality, so router spans are named after their route.
const isStreamedRouterSpan = layerType === LAYER_TYPE.ROUTER && !!client && hasSpanStreamingEnabled(client);

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 calls

Low Severity

Flagged because it was mentioned in the review rules file — this is more an "is this necessary" check than a hard violation. These sites newly call getClient() to gate span streaming, while the Koa, Express, and Hapi integrations already receive a client in setup. Prefering that existing reference would avoid relying on ambient current-client state in multi-client setups.

Additional Locations (2)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit be3a06a. Configure here.

description: 'Router',
},
]);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing integration or E2E tests

Low Severity

Flagged because it was mentioned in the review rules file. This is a feat PR, and the new coverage is package-level unit tests (Express patch-layer, Hapi utils, SvelteKit). The guidelines ask for at least one integration or E2E test so the streamed router naming is exercised against a real framework request or navigation path.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit be3a06a. Configure here.

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 router span names

2 participants