Skip to content

Commit 5fac11c

Browse files
authored
Update AWS SDK middleware patch to use global propagator instead of X-Ray propagator (#220)
*Issue #, if available:* *Description of changes:* Update AWS SDK middleware patch to use global propagator instead of X-Ray propagator By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent a6b8380 commit 5fac11c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

aws-distro-opentelemetry-node-autoinstrumentation/src/patches/instrumentation-patch.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ function patchAwsLambdaInstrumentation(instrumentation: Instrumentation): void {
295295

296296
// Override the upstream private _getV3SmithyClientSendPatch method to add middleware to inject X-Ray Trace Context into HTTP Headers
297297
// https://github.com/open-telemetry/opentelemetry-js-contrib/blob/instrumentation-aws-sdk-v0.48.0/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts#L373-L384
298-
const awsXrayPropagator = new AWSXRayPropagator();
299298
const V3_CLIENT_CONFIG_KEY = Symbol('opentelemetry.instrumentation.aws-sdk.client.config');
300299
type V3PluginCommand = AwsV3Command<any, any, any, any, any> & {
301300
[V3_CLIENT_CONFIG_KEY]?: any;
@@ -308,7 +307,7 @@ function patchAwsSdkInstrumentation(instrumentation: Instrumentation): void {
308307
return function send(this: any, command: V3PluginCommand, ...args: unknown[]): Promise<any> {
309308
this.middlewareStack?.add(
310309
(next: any, context: any) => async (middlewareArgs: any) => {
311-
awsXrayPropagator.inject(otelContext.active(), middlewareArgs.request.headers, defaultTextMapSetter);
310+
propagation.inject(otelContext.active(), middlewareArgs.request.headers, defaultTextMapSetter);
312311
// Need to set capitalized version of the trace id to ensure that the Recursion Detection Middleware
313312
// of aws-sdk-js-v3 will detect the propagated X-Ray Context
314313
// See: https://github.com/aws/aws-sdk-js-v3/blob/v3.768.0/packages/middleware-recursion-detection/src/index.ts#L13

0 commit comments

Comments
 (0)