Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: Add http.route attribute to http.server spans with parameterized routes#22534
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
6cb8b0de6a4020426bf50ca1f7c1e7ef437ae9c5fa10f9515cbb02caFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -15,6 +15,7 @@ import { defaultShouldHandleError } from './defaultShouldHandleError'; | ||
| import { resolveRouteName } from './resolveRouteName'; | ||
| import { type SentryHonoMiddlewareOptions } from '../shared/types'; | ||
| import { type GetConnInfo } from 'hono/conninfo'; | ||
| import { HTTP_ROUTE } from '@sentry/conventions/attributes'; | ||
| /** | ||
| * Request handler for Hono framework | ||
| @@ -99,7 +100,8 @@ export function responseHandler( | ||
| } | ||
| function updateSpanRouteName(isolationScope: Scope, context: Context): void { | ||
| const routeName = `${context.req.method} ${resolveRouteName(context)}`; | ||
| const route = resolveRouteName(context); | ||
| const routeName = `${context.req.method} ${route}`; | ||
| const activeSpan = getActiveSpan(); | ||
| if (activeSpan) { | ||
| @@ -108,7 +110,10 @@ function updateSpanRouteName(isolationScope: Scope, context: Context): void { | ||
| const rootSpan = getRootSpan(activeSpan); | ||
| updateSpanName(rootSpan, routeName); | ||
| rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route'); | ||
| rootSpan.setAttributes({ | ||
| [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route', | ||
| [HTTP_ROUTE]: route, | ||
| }); | ||
cursor[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| isolationScope.setTransactionName(routeName); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -47,6 +47,7 @@ export function enhanceHandleRequestRootSpan(span: MutableRootSpan): void { | ||
| const cleanRoute = route.replace(/\/route$/, ''); | ||
| span.setName(`${method} ${cleanRoute}`); | ||
| attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] = 'route'; | ||
| attributes[HTTP_ROUTE] = cleanRoute; | ||
| // Preserve next.route in case it did not get hoisted | ||
| attributes[ATTR_NEXT_ROUTE] = cleanRoute; | ||
| } | ||
| @@ -55,6 +56,7 @@ export function enhanceHandleRequestRootSpan(span: MutableRootSpan): void { | ||
| const routeBackfill = attributes[TRANSACTION_ATTR_SENTRY_ROUTE_BACKFILL]; | ||
| if (typeof routeBackfill === 'string' && span.getName() !== 'GET /_app') { | ||
| span.setName(`${typeof method === 'string' ? method : 'GET'} ${routeBackfill}`); | ||
| attributes[HTTP_ROUTE] = attributes[HTTP_ROUTE] ?? routeBackfill; | ||
cursor[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. cursor[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. Lms24 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| const middlewareMatch = | ||
sentry[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.