-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(core): Emit low cardinality router span names #23547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,11 @@ import { | |
| debug, | ||
| defineIntegration, | ||
| getActiveSpan, | ||
| getClient, | ||
| getDefaultIsolationScope, | ||
| getIsolationScope, | ||
| hasSpanStreamingEnabled, | ||
| ROUTER_SPAN_NAME_FALLBACK, | ||
| SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, | ||
| startSpan, | ||
| } from '@sentry/core'; | ||
|
|
@@ -173,7 +176,12 @@ function patchLayer( | |
| const koaName = metadata.attributes[KOA_NAME]; | ||
| // Somehow, name is sometimes `''` for middleware spans. | ||
| // See: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2220 | ||
| const name = typeof koaName === 'string' ? koaName || '< unknown >' : metadata.name; | ||
| const staticName = typeof koaName === 'string' ? koaName || '< unknown >' : metadata.name; | ||
|
|
||
| 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoidable getClient callsLow 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 Additional Locations (2)Triggered by project rule: PR Review Guidelines for Cursor Bot Reviewed by Cursor Bugbot for commit be3a06a. Configure here. |
||
| const name = isStreamedRouterSpan ? metadata.attributes[HTTP_ROUTE] || ROUTER_SPAN_NAME_FALLBACK : staticName; | ||
|
|
||
| return startSpan( | ||
| { | ||
|
|
||


There was a problem hiding this comment.
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
featPR, 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 streamedrouternaming 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.