Skip to content

Commit 8068977

Browse files
committed
fix(node): keep fastify routerPath for backwards compatibility
1 parent 2d9d342 commit 8068977

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/node/src/integrations/tracing/fastify.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ interface FastifyRequestRouteInfo {
3030
url?: string;
3131
method?: string;
3232
};
33+
// will deprecate in Fastify 5
34+
routerPath?: string;
3335
}
3436

3537
const INTEGRATION_NAME = 'Fastify';
@@ -78,7 +80,8 @@ export function setupFastifyErrorHandler(fastify: Fastify): void {
7880

7981
// Taken from Otel Fastify instrumentation:
8082
// https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts#L94-L96
81-
const routeName = reqWithRouteInfo.routeOptions?.url;
83+
const routeName = reqWithRouteInfo.routeOptions ? reqWithRouteInfo.routeOptions.url : reqWithRouteInfo.routerPath;
84+
8285
const method = reqWithRouteInfo.routeOptions?.method || 'GET';
8386

8487
getIsolationScope().setTransactionName(`${method} ${routeName}`);

0 commit comments

Comments
 (0)