MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / updateRouteTransactionName

Function updateRouteTransactionName

packages/elysia/src/withElysia.ts:59–78  ·  view source on GitHub ↗

* Updates the root span and isolation scope with the parameterized route name.

(request: Request, method: string, route: string)

Source from the content-addressed store, hash-verified

57 * Updates the root span and isolation scope with the parameterized route name.
58 */
59function updateRouteTransactionName(request: Request, method: string, route: string): void {
60 const transactionName = `${method} ${route}`;
61
62 // Try the stored root span first (reliable across async contexts),
63 // then fall back to getActiveSpan() for cases where async context is preserved.
64 const rootSpan = rootSpanForRequest.get(request);
65 if (rootSpan) {
66 updateSpanName(rootSpan, transactionName);
67 rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');
68 } else {
69 const activeSpan = getActiveSpan();
70 if (activeSpan) {
71 const root = getRootSpan(activeSpan);
72 updateSpanName(root, transactionName);
73 root.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');
74 }
75 }
76
77 getIsolationScope().setTransactionName(transactionName);
78}
79
80function defaultShouldHandleError(context: ErrorContext): boolean {
81 const status = context.set.status;

Callers 1

withElysiaFunction · 0.85

Calls 7

updateSpanNameFunction · 0.90
getActiveSpanFunction · 0.90
getIsolationScopeFunction · 0.90
getRootSpanFunction · 0.85
setTransactionNameMethod · 0.80
getMethod · 0.65
setAttributeMethod · 0.65

Tested by

no test coverage detected