File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
aws-distro-opentelemetry-node-autoinstrumentation/src/patches Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -311,9 +311,12 @@ function patchAwsSdkInstrumentation(instrumentation: Instrumentation): void {
311311 // Need to set capitalized version of the trace id to ensure that the Recursion Detection Middleware
312312 // of aws-sdk-js-v3 will detect the propagated X-Ray Context
313313 // See: https://github.com/aws/aws-sdk-js-v3/blob/v3.768.0/packages/middleware-recursion-detection/src/index.ts#L13
314- middlewareArgs . request . headers [ AWSXRAY_TRACE_ID_HEADER_CAPITALIZED ] =
315- middlewareArgs . request . headers [ AWSXRAY_TRACE_ID_HEADER ] ;
316- delete middlewareArgs . request . headers [ AWSXRAY_TRACE_ID_HEADER ] ;
314+ const xray_trace_id = middlewareArgs . request . headers [ AWSXRAY_TRACE_ID_HEADER ] ;
315+
316+ if ( xray_trace_id ) {
317+ middlewareArgs . request . headers [ AWSXRAY_TRACE_ID_HEADER_CAPITALIZED ] = xray_trace_id ;
318+ delete middlewareArgs . request . headers [ AWSXRAY_TRACE_ID_HEADER ] ;
319+ }
317320 const result = await next ( middlewareArgs ) ;
318321 return result ;
319322 } ,
You can’t perform that action at this time.
0 commit comments