feat(core): Emit low cardinality router span names - #23547
Conversation
size-limit report 📦
|
5d83782 to
1318630
Compare
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.
1318630 to
be3a06a
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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); |
There was a problem hiding this comment.
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)
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit be3a06a. Configure here.
| description: 'Router', | ||
| }, | ||
| ]); | ||
| }); |
There was a problem hiding this comment.
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.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit be3a06a. Configure here.


Names
routerspans after the route they dispatch when span streaming is enabled, elseRouter. Static mode is unchanged./cmount pathhttp.route/users/123http.route/users/:idRouterif pathlessGET /users/{id}/users/{id}/users/123Routerroute:a -> route:bRouterSvelteKit Route ChangeRouterOnly Koa already used its
http.route. Hapi drops the method since the template has none; Angular, Ember and SvelteKit carry no route.closes #23532