From 6804892356b352c80047192c958e6e59edab95a2 Mon Sep 17 00:00:00 2001 From: Onur Temizkan Date: Thu, 25 Jul 2024 17:35:06 +0100 Subject: [PATCH] Update `getRouterPath` --- .../node/opentelemetry-instrumentation-express/src/utils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-express/src/utils.ts b/plugins/node/opentelemetry-instrumentation-express/src/utils.ts index 76b26ce634..fdc8f3728c 100644 --- a/plugins/node/opentelemetry-instrumentation-express/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-express/src/utils.ts @@ -51,13 +51,13 @@ export const storeLayerPath = (request: PatchedRequest, value?: string) => { * @returns The reconstructed path */ export const getRouterPath = (path: string, layer: ExpressLayer): string => { - const stackLayer = layer.handle?.stack[0]; + const stackLayer = layer.handle?.stack?.[0]; - if (stackLayer.route?.path) { + if (stackLayer?.route?.path) { return `${path}${stackLayer.route.path}`; } - if (stackLayer.handle?.stack) { + if (stackLayer?.handle?.stack) { return getRouterPath(path, stackLayer); }