1
+ import { IncomingMessage } from 'http' ;
2
+
3
+ import type { Request } from 'express' ;
1
4
import type { Instrumentation } from '@opentelemetry/instrumentation' ;
2
5
import { DnsInstrumentation } from '@opentelemetry/instrumentation-dns' ;
3
6
import { ExpressInstrumentation , ExpressInstrumentationConfig } from '@opentelemetry/instrumentation-express' ;
@@ -8,9 +11,6 @@ import { IORedisInstrumentation } from '@opentelemetry/instrumentation-ioredis';
8
11
import { NetInstrumentation } from '@opentelemetry/instrumentation-net' ;
9
12
import { PgInstrumentation } from '@opentelemetry/instrumentation-pg' ;
10
13
import { PinoInstrumentation } from '@opentelemetry/instrumentation-pino' ;
11
- import { Span } from '@opentelemetry/api' ;
12
- import { IncomingMessage , ClientRequest } from 'http' ;
13
- import { Request } from 'express' ;
14
14
15
15
const InstrumentationMap = {
16
16
'@opentelemetry/instrumentation-http' : HttpInstrumentation ,
@@ -74,7 +74,7 @@ export function getAutoInstrumentations(
74
74
expressConfig . requestHook = ( span , req ) => {
75
75
const method = req . request ?. method || 'UNKNOWN' ;
76
76
// Use the matched route path instead of raw URL if available
77
- const route = ( req . request as any ) . route ?. path || req . request ?. url ?. split ( '?' ) [ 0 ] || '/' ;
77
+ const route = ( req . request as Request ) . route ?. path || req . request ?. url ?. split ( '?' ) [ 0 ] || '/' ;
78
78
span . updateName ( createSpanName ( method , route ) ) ;
79
79
} ;
80
80
}
0 commit comments