Skip to content

Commit f2e0f77

Browse files
authored
Ensure envDetector will override any conflicting resource attributes (#53)
*Issue #, if available:* *Description of changes:* - Move `envDetectorSync` to the end of the `defaultDetectors` list. 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 57138e7 commit f2e0f77

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ import {
5353
import { SEMRESATTRS_TELEMETRY_AUTO_VERSION } from '@opentelemetry/semantic-conventions';
5454
import { AlwaysRecordSampler } from './always-record-sampler';
5555
import { AttributePropagatingSpanProcessorBuilder } from './attribute-propagating-span-processor-builder';
56+
import { AwsBatchUnsampledSpanProcessor } from './aws-batch-unsampled-span-processor';
5657
import { AwsMetricAttributesSpanExporterBuilder } from './aws-metric-attributes-span-exporter-builder';
5758
import { AwsSpanMetricsProcessorBuilder } from './aws-span-metrics-processor-builder';
59+
import { OTLPUdpSpanExporter } from './otlp-udp-exporter';
5860
import { AwsXRayRemoteSampler } from './sampler/aws-xray-remote-sampler';
5961
// This file is generated via `npm run compile`
6062
import { LIB_VERSION } from './version';
61-
import { OTLPUdpSpanExporter } from './otlp-udp-exporter';
62-
import { AwsBatchUnsampledSpanProcessor } from './aws-batch-unsampled-span-processor';
6363

6464
const APPLICATION_SIGNALS_ENABLED_CONFIG: string = 'OTEL_AWS_APPLICATION_SIGNALS_ENABLED';
6565
const APPLICATION_SIGNALS_EXPORTER_ENDPOINT_CONFIG: string = 'OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT';
@@ -133,14 +133,16 @@ export class AwsOpentelemetryConfigurator {
133133
* envDetectorSync is used as opposed to envDetector (async), so it is guaranteed that the
134134
* resource is populated with configured OTEL_RESOURCE_ATTRIBUTES or OTEL_SERVICE_NAME env
135135
* var values by the time that this class provides a configuration to the OTel SDK.
136+
*
137+
* envDetectorSync needs to be last so it can override any conflicting resource attributes.
136138
*/
137139
defaultDetectors = [
138-
envDetectorSync,
139140
processDetector,
140141
hostDetector,
141142
awsEc2Detector,
142143
awsEcsDetector,
143144
awsEksDetector,
145+
envDetectorSync,
144146
];
145147
}
146148

0 commit comments

Comments
 (0)