Skip to content

Check for undefined XRay Trace Id in AwsSdk Instrumentation #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 8, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,12 @@ function patchAwsSdkInstrumentation(instrumentation: Instrumentation): void {
// Need to set capitalized version of the trace id to ensure that the Recursion Detection Middleware
// of aws-sdk-js-v3 will detect the propagated X-Ray Context
// See: https://github.com/aws/aws-sdk-js-v3/blob/v3.768.0/packages/middleware-recursion-detection/src/index.ts#L13
middlewareArgs.request.headers[AWSXRAY_TRACE_ID_HEADER_CAPITALIZED] =
middlewareArgs.request.headers[AWSXRAY_TRACE_ID_HEADER];
delete middlewareArgs.request.headers[AWSXRAY_TRACE_ID_HEADER];
const xray_trace_id = middlewareArgs.request.headers[AWSXRAY_TRACE_ID_HEADER];

if (xray_trace_id) {
middlewareArgs.request.headers[AWSXRAY_TRACE_ID_HEADER_CAPITALIZED] = xray_trace_id;
delete middlewareArgs.request.headers[AWSXRAY_TRACE_ID_HEADER];
}
const result = await next(middlewareArgs);
return result;
},
Expand Down
Loading