Skip to content

Commit 33a52b3

Browse files
committed
restore auto-configuration-propagator feature
1 parent 740ec38 commit 33a52b3

File tree

3 files changed

+51
-38
lines changed

3 files changed

+51
-38
lines changed

aws-distro-opentelemetry-node-autoinstrumentation/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
},
104104
"dependencies": {
105105
"@opentelemetry/api": "1.9.0",
106+
"@opentelemetry/auto-configuration-propagators": "0.3.2",
106107
"@opentelemetry/auto-instrumentations-node": "0.56.0",
107108
"@opentelemetry/core": "1.30.1",
108109
"@opentelemetry/exporter-metrics-otlp-grpc": "0.57.1",

aws-distro-opentelemetry-node-autoinstrumentation/src/aws-opentelemetry-configurator.ts

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
// Modifications Copyright The OpenTelemetry Authors. Licensed under the Apache License 2.0 License.
44

55
import { TextMapPropagator, diag } from '@opentelemetry/api';
6+
import { getPropagator } from '@opentelemetry/auto-configuration-propagators';
67
import { getResourceDetectors as getResourceDetectorsFromEnv } from '@opentelemetry/auto-instrumentations-node';
78
import {
8-
CompositePropagator,
99
ENVIRONMENT,
1010
TracesSamplerValues,
1111
getEnv,
1212
getEnvWithoutDefaults,
13-
W3CBaggagePropagator,
14-
W3CTraceContextPropagator,
1513
} from '@opentelemetry/core';
1614
import { OTLPMetricExporter as OTLPGrpcOTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc';
1715
import {
@@ -24,8 +22,6 @@ import { OTLPTraceExporter as OTLPProtoTraceExporter } from '@opentelemetry/expo
2422
import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
2523
import { AWSXRayIdGenerator } from '@opentelemetry/id-generator-aws-xray';
2624
import { Instrumentation } from '@opentelemetry/instrumentation';
27-
import { AWSXRayPropagator } from '@opentelemetry/propagator-aws-xray';
28-
import { AWSXRayLambdaPropagator } from '@opentelemetry/propagator-aws-xray-lambda';
2925
import { awsEc2DetectorSync, awsEcsDetectorSync, awsEksDetectorSync } from '@opentelemetry/resource-detector-aws';
3026
import {
3127
Detector,
@@ -85,12 +81,6 @@ const FORMAT_OTEL_UNSAMPLED_TRACES_BINARY_PREFIX = 'T1U';
8581
// which will reduce the chance of UDP package size is larger than 64KB
8682
const LAMBDA_SPAN_EXPORT_BATCH_SIZE = 10;
8783

88-
const propagatorMap = new Map<string, () => TextMapPropagator>([
89-
['tracecontext', () => new W3CTraceContextPropagator()],
90-
['baggage', () => new W3CBaggagePropagator()],
91-
['xray', () => new AWSXRayPropagator()],
92-
['xray-lambda', () => new AWSXRayLambdaPropagator()],
93-
]);
9484
/**
9585
* Aws Application Signals Config Provider creates a configuration object that can be provided to
9686
* the OTel NodeJS SDK for Auto Instrumentation with Application Signals Functionality.
@@ -179,7 +169,7 @@ export class AwsOpentelemetryConfigurator {
179169
this.resource = autoResource;
180170

181171
this.instrumentations = instrumentations;
182-
this.propagator = this.getPropagator();
172+
this.propagator = getPropagator();
183173

184174
// TODO: Consider removing AWSXRayIdGenerator as it is not needed
185175
// Similarly to Java, always use AWS X-Ray Id Generator
@@ -206,32 +196,6 @@ export class AwsOpentelemetryConfigurator {
206196
return autoResource;
207197
}
208198

209-
private getPropagator(): TextMapPropagator {
210-
if (process.env.OTEL_PROPAGATORS == null || process.env.OTEL_PROPAGATORS.trim() === '') {
211-
return new CompositePropagator({
212-
propagators: [new W3CTraceContextPropagator(), new W3CBaggagePropagator()],
213-
});
214-
}
215-
const propagatorsFromEnv = Array.from(
216-
new Set(process.env.OTEL_PROPAGATORS?.split(',').map(value => value.toLowerCase().trim()))
217-
);
218-
const propagators = propagatorsFromEnv.flatMap(propagatorName => {
219-
if (propagatorName === 'none') {
220-
diag.info(
221-
'Not selecting any propagator for value "none" specified in the environment variable OTEL_PROPAGATORS'
222-
);
223-
return [];
224-
}
225-
const propagatorFactoryFunction = propagatorMap.get(propagatorName);
226-
if (propagatorFactoryFunction == null) {
227-
diag.warn(`Invalid propagator "${propagatorName}" specified in the environment variable OTEL_PROPAGATORS`);
228-
return [];
229-
}
230-
return propagatorFactoryFunction();
231-
});
232-
return new CompositePropagator({ propagators });
233-
}
234-
235199
public configure(): Partial<NodeSDKConfiguration> {
236200
// config.autoDetectResources is set to False, as the resources are detected and added to the
237201
// resource ahead of time. The resource is needed to be populated ahead of time instead of letting

package-lock.json

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)