Skip to content

Commit e733556

Browse files
committed
remove updateSpanName
1 parent 7da3667 commit e733556

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

packages/nuxt/src/runtime/hooks/updateRouteBeforeResponse.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,32 @@ export function updateRouteBeforeResponse(event: H3Event): void {
2626
getCurrentScope().setTransactionName(parametrizedTransactionName);
2727

2828
const activeSpan = getActiveSpan(); // In development mode, getActiveSpan() is always undefined
29-
if (activeSpan) {
30-
const rootSpan = getRootSpan(activeSpan);
31-
if (rootSpan) {
32-
rootSpan.updateName(parametrizedTransactionName);
33-
rootSpan.setAttributes({
34-
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
35-
'http.route': matchedRoutePath,
36-
});
29+
if (!activeSpan) {
30+
return;
31+
}
32+
33+
const rootSpan = getRootSpan(activeSpan);
34+
if (!rootSpan) {
35+
return;
36+
}
3737

38-
const params = event.context?.params;
38+
rootSpan.setAttributes({
39+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
40+
'http.route': matchedRoutePath,
41+
});
3942

40-
if (params && typeof params === 'object') {
41-
Object.entries(params).forEach(([key, value]) => {
42-
// Based on this convention: https://getsentry.github.io/sentry-conventions/generated/attributes/url.html#urlpathparameterkey
43-
rootSpan.setAttribute(`url.path.parameter.${key}`, String(value));
44-
});
45-
}
43+
const params = event.context?.params;
4644

47-
logger.log(`Updated transaction name for parametrized route: ${parametrizedTransactionName}`);
48-
}
45+
if (params && typeof params === 'object') {
46+
Object.entries(params).forEach(([key, value]) => {
47+
// Based on this convention: https://getsentry.github.io/sentry-conventions/generated/attributes/url.html#urlpathparameterkey
48+
rootSpan.setAttributes({
49+
[`url.path.parameter.${key}`]: String(value),
50+
[`params.${key}`]: String(value),
51+
});
52+
});
4953
}
54+
55+
logger.log(`Updated transaction name for parametrized route: ${parametrizedTransactionName}`);
5056
}
5157
}

0 commit comments

Comments
 (0)