Skip to content

Commit f342341

Browse files
authored
ref(router): Align route params with semantic conventions (#16828)
Rename based on https://getsentry.github.io/sentry-conventions/generated/attributes/url.html#urlpathparameterkey
1 parent ff82f2b commit f342341

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

packages/react/src/tanstackrouter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ function routeMatchToParamSpanAttributes(match: VendoredTanstackRouterRouteMatch
119119

120120
const paramAttributes: Record<string, string> = {};
121121
Object.entries(match.params).forEach(([key, value]) => {
122-
paramAttributes[`url.path.params.${key}`] = value;
122+
paramAttributes[`url.path.params.${key}`] = value; // todo(v10): remove attribute which does not adhere to Sentry's semantic convention
123+
paramAttributes[`url.path.parameter.${key}`] = value;
124+
paramAttributes[`params.${key}`] = value; // params.[key] is an alias
123125
});
124126

125127
return paramAttributes;

packages/vue/src/router.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export function instrumentVueRouter(
6161
const attributes: SpanAttributes = {};
6262

6363
for (const key of Object.keys(to.params)) {
64-
attributes[`params.${key}`] = to.params[key];
64+
attributes[`url.path.parameter.${key}`] = to.params[key];
65+
attributes[`params.${key}`] = to.params[key]; // params.[key] is an alias
6566
}
6667
for (const key of Object.keys(to.query)) {
6768
const value = to.query[key];

packages/vue/test/router.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ function getAttributesForRoute(route: Route): SpanAttributes {
423423
const attributes: SpanAttributes = {};
424424

425425
for (const key of Object.keys(params)) {
426+
attributes[`url.path.parameter.${key}`] = params[key];
426427
attributes[`params.${key}`] = params[key];
427428
}
428429
for (const key of Object.keys(query)) {

0 commit comments

Comments
 (0)