fix(nextjs): Treat static route span names as low-cardinality names - #23503
Conversation
size-limit report 📦
|
`findMatchingRoutes` returned nothing for a path that exactly matched a static route in the build-time manifest, so `maybeParameterizeRoute` reported it the same way as a path it could not resolve at all: no manifest, a 404, or a route excluded from the manifest. Static routes were therefore emitted with `sentry.source: 'url'` and no `url.template`, even though a static route is its own template - one with zero parameters - and is guaranteed low cardinality by the finite build-time route list. Return the route itself instead. Pageload, navigation, popstate and router-patch spans all derive their name, source and `url.template` from that return value, so static routes now carry `sentry.source: 'route'`. Under span streaming they keep their path as the span name instead of collapsing to `Pageload`, which is now reserved for paths the manifest genuinely cannot resolve. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
b7a6a70 to
b6f7b8f
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.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b6f7b8f. Configure here.
| expect(serverSpan.trace_id).toBe(pageloadSpan.trace_id); | ||
| expect(pageloadSpan.attributes).toMatchObject({ | ||
| ['sentry.segment.name.source']: { value: 'url', type: 'string' }, | ||
| ['sentry.segment.name.source']: { value: 'route', type: 'string' }, |
There was a problem hiding this comment.
Incomplete static route assertions
Low Severity
Flagged because the PR review guidelines ask to assert newly added payload data thoroughly. This test updates sentry.segment.name.source to route for the static /pageload-tracing pageload, but does not assert url.template, which sibling updates in this PR (for example the cacheComponents and parameterized static tests) do cover.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit b6f7b8f. Configure here.
| expect(span.attributes).toMatchObject({ | ||
| ['sentry.segment.name.source']: { value: 'url', type: 'string' }, | ||
| ['url.path']: { value: '/parameterized/static', type: 'string' }, | ||
| ['url.path']: { value: '/this-route-does-not-exist', type: 'string' }, |
There was a problem hiding this comment.
Missing negative template assertion
Low Severity
Flagged because the PR review guidelines call out relaxed matchers when a payload field is expected to be absent. This new unknown-route fallback test uses toMatchObject for source: 'url' but never asserts that url.template is missing, even though that attribute is only set when a manifest match exists.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit b6f7b8f. Configure here.
…23503) This PR fixes a "bug" in which we annotated static (paramter-less) routes as high-cardinality (`source: 'url'`) unparamterized URL span names. While these routes do not contain a parameter, we can still guarantee that we resolved them to a static route (via the manifest route matching), so we should annotate it as low card. (`source: 'route'`). --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>


This PR fixes a "bug" in which we annotated static (paramter-less) routes as high-cardinality (
source: 'url') unparamterized URL span names. While these routes do not contain a parameter, we can still guarantee that we resolved them to a static route (via the manifest route matching), so we should annotate it as low card. (source: 'route').