@@ -4,6 +4,7 @@ import type { ExpressRequestInfo } from '@opentelemetry/instrumentation-express'
44import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express' ;
55import type { IntegrationFn } from '@sentry/core' ;
66import {
7+ httpRequestToRequestData ,
78 SEMANTIC_ATTRIBUTE_SENTRY_OP ,
89 captureException ,
910 defineIntegration ,
@@ -135,9 +136,10 @@ export function expressErrorHandler(options?: ExpressHandlerOptions): ExpressErr
135136 res : http . ServerResponse ,
136137 next : ( error : MiddlewareError ) => void ,
137138 ) : void {
139+ const normalizedRequest = httpRequestToRequestData ( request ) ;
138140 // Ensure we use the express-enhanced request here, instead of the plain HTTP one
139141 // When an error happens, the `expressRequestHandler` middleware does not run, so we set it here too
140- getIsolationScope ( ) . setSDKProcessingMetadata ( { request } ) ;
142+ getIsolationScope ( ) . setSDKProcessingMetadata ( { normalizedRequest } ) ;
141143
142144 const shouldHandleError = options ?. shouldHandleError || defaultShouldHandleError ;
143145
@@ -156,8 +158,9 @@ function expressRequestHandler(): ExpressMiddleware {
156158 _res : http . ServerResponse ,
157159 next : ( ) => void ,
158160 ) : void {
161+ const normalizedRequest = httpRequestToRequestData ( request ) ;
159162 // Ensure we use the express-enhanced request here, instead of the plain HTTP one
160- getIsolationScope ( ) . setSDKProcessingMetadata ( { request } ) ;
163+ getIsolationScope ( ) . setSDKProcessingMetadata ( { normalizedRequest } ) ;
161164
162165 next ( ) ;
163166 } ;
0 commit comments