File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
plugins/node/opentelemetry-instrumentation-express Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -266,6 +266,16 @@ export function getActualMatchedRoute(req: {
266266 return constructedRoute ;
267267 }
268268
269+ // For RegExp routes or route arrays, return the constructed route
270+ // This handles the case where the route is defined using RegExp or an array
271+ if ( constructedRoute . includes ( '/' ) &&
272+ ( constructedRoute . includes ( ',' ) ||
273+ constructedRoute . includes ( '\\' ) ||
274+ constructedRoute . includes ( '*' ) ||
275+ constructedRoute . includes ( '[' ) ) ) {
276+ return constructedRoute ;
277+ }
278+
269279 // Ensure route starts with '/' if it doesn't already
270280 const normalizedRoute = constructedRoute . startsWith ( '/' )
271281 ? constructedRoute
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ describe('ExpressInstrumentation', () => {
103103
104104 for ( const span of spans ) {
105105 assert . strictEqual (
106- span . attributes [ SEMATTRS_HTTP_ROUTE ] ,
106+ span . attributes [ ATTR_HTTP_ROUTE ] ,
107107 undefined , // none of the spans have the HTTP route attribute
108108 `Span "${ span . name } " should not have HTTP route attribute for non-existing route`
109109 ) ;
You can’t perform that action at this time.
0 commit comments