Skip to content

Commit cab9e49

Browse files
committed
remove b3 and jaeger propagator transitive dependencies
1 parent 718bbec commit cab9e49

File tree

5 files changed

+68
-71
lines changed

5 files changed

+68
-71
lines changed

aws-distro-opentelemetry-node-autoinstrumentation/install-externals.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
"clean": "rimraf build/*",
2525
"compile:tsc": "tsc -p .",
2626
"compile:webpack": "webpack",
27-
"compile": "npm run compile:webpack && npm run install-externals",
28-
"install-externals": "./install-externals.sh",
27+
"compile": "npm run compile:webpack",
2928
"lint": "eslint . --ext .ts",
3029
"lint:fix": "eslint . --ext .ts --fix",
3130
"create-version": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
@@ -104,7 +103,6 @@
104103
},
105104
"dependencies": {
106105
"@opentelemetry/api": "1.9.0",
107-
"@opentelemetry/auto-configuration-propagators": "0.3.0",
108106
"@opentelemetry/auto-instrumentations-node": "0.50.0",
109107
"@opentelemetry/core": "1.26.0",
110108
"@opentelemetry/exporter-metrics-otlp-grpc": "0.53.0",
@@ -116,6 +114,7 @@
116114
"@opentelemetry/instrumentation-aws-sdk": "0.44.0",
117115
"@opentelemetry/otlp-transformer": "0.53.0",
118116
"@opentelemetry/propagator-aws-xray": "1.26.0",
117+
"@opentelemetry/propagator-aws-xray-lambda": "^0.53.2",
119118
"@opentelemetry/resource-detector-aws": "1.12.0",
120119
"@opentelemetry/resources": "1.26.0",
121120
"@opentelemetry/sdk-metrics": "1.26.0",

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

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
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';
76
import { getResourceDetectors as getResourceDetectorsFromEnv } from '@opentelemetry/auto-instrumentations-node';
8-
import { ENVIRONMENT, TracesSamplerValues, getEnv, getEnvWithoutDefaults } from '@opentelemetry/core';
7+
import { CompositePropagator, ENVIRONMENT, TracesSamplerValues, getEnv, getEnvWithoutDefaults, W3CBaggagePropagator, W3CTraceContextPropagator } from '@opentelemetry/core';
98
import { OTLPMetricExporter as OTLPGrpcOTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc';
109
import {
1110
AggregationTemporalityPreference,
@@ -17,6 +16,8 @@ import { OTLPTraceExporter as OTLPProtoTraceExporter } from '@opentelemetry/expo
1716
import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
1817
import { AWSXRayIdGenerator } from '@opentelemetry/id-generator-aws-xray';
1918
import { Instrumentation } from '@opentelemetry/instrumentation';
19+
import { AWSXRayPropagator } from '@opentelemetry/propagator-aws-xray';
20+
import { AWSXRayLambdaPropagator } from '@opentelemetry/propagator-aws-xray-lambda';
2021
import { awsEc2DetectorSync, awsEcsDetectorSync, awsEksDetectorSync } from '@opentelemetry/resource-detector-aws';
2122
import {
2223
Detector,
@@ -75,6 +76,13 @@ const FORMAT_OTEL_UNSAMPLED_TRACES_BINARY_PREFIX = 'T1U';
7576
// Follow Python SDK Impl to set the max span batch size
7677
// which will reduce the chance of UDP package size is larger than 64KB
7778
const LAMBDA_SPAN_EXPORT_BATCH_SIZE = 10;
79+
80+
const propagatorMap = new Map<string, () => TextMapPropagator>([
81+
['tracecontext', () => new W3CTraceContextPropagator()],
82+
['baggage', () => new W3CBaggagePropagator()],
83+
['xray', () => new AWSXRayPropagator()],
84+
['xray-lambda', () => new AWSXRayLambdaPropagator()],
85+
]);
7886
/**
7987
* Aws Application Signals Config Provider creates a configuration object that can be provided to
8088
* the OTel NodeJS SDK for Auto Instrumentation with Application Signals Functionality.
@@ -163,7 +171,7 @@ export class AwsOpentelemetryConfigurator {
163171
this.resource = autoResource;
164172

165173
this.instrumentations = instrumentations;
166-
this.propagator = getPropagator();
174+
this.propagator = this.getPropagator();
167175

168176
// TODO: Consider removing AWSXRayIdGenerator as it is not needed
169177
// Similarly to Java, always use AWS X-Ray Id Generator
@@ -190,6 +198,44 @@ export class AwsOpentelemetryConfigurator {
190198
return autoResource;
191199
}
192200

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

aws-distro-opentelemetry-node-autoinstrumentation/webpack.config.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ module.exports = {
55
target: 'node',
66
mode: 'production',
77
externalsPresets: { node: true },
8-
externals: [
9-
'import-in-the-middle',
10-
],
118
output: {
129
path: path.resolve('./build/src'),
1310
filename: 'register.js',

package-lock.json

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

0 commit comments

Comments
 (0)