Skip to content

Commit 59d1adb

Browse files
authored
use sync resource detectors (#112)
*Issue #, if available:* *Description of changes:* Due to a [bug](open-telemetry/opentelemetry-js#4687) in upstream, the `detectResourcesSync` doesn't wait for the async attributes. This happens if we use the async version of some resource detector. The [fix](open-telemetry/opentelemetry-js#4687) is in another upstream release. We don't want to upgrade the upstream version for now. To avoid this issue, we switch to the sync version of the detectors and this should have no impact for the functionalities (as `detectResourcesSync` waits for all async detectors anyway and works for both sync and async detectors). In the future, even if we upgrade upstream version, we don't need to switch back to async detectors. 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 b6d2752 commit 59d1adb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { OTLPTraceExporter as OTLPProtoTraceExporter } from '@opentelemetry/expo
1717
import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
1818
import { AWSXRayIdGenerator } from '@opentelemetry/id-generator-aws-xray';
1919
import { Instrumentation } from '@opentelemetry/instrumentation';
20-
import { awsEc2Detector, awsEcsDetector, awsEksDetector } from '@opentelemetry/resource-detector-aws';
20+
import { awsEc2DetectorSync, awsEcsDetectorSync, awsEksDetectorSync } from '@opentelemetry/resource-detector-aws';
2121
import {
2222
Detector,
2323
DetectorSync,
@@ -126,7 +126,7 @@ export class AwsOpentelemetryConfigurator {
126126
// Add Env/AWS Resource Detectors if not present
127127
const resourceDetectorsFromEnv: string[] = process.env.OTEL_NODE_RESOURCE_DETECTORS.split(',');
128128
if (!resourceDetectorsFromEnv.includes('aws')) {
129-
defaultDetectors.push(awsEc2Detector, awsEcsDetector, awsEksDetector);
129+
defaultDetectors.push(awsEc2DetectorSync, awsEcsDetectorSync, awsEksDetectorSync);
130130
}
131131
if (!resourceDetectorsFromEnv.includes('env')) {
132132
defaultDetectors.push(envDetectorSync);
@@ -145,9 +145,9 @@ export class AwsOpentelemetryConfigurator {
145145
defaultDetectors = [
146146
processDetector,
147147
hostDetector,
148-
awsEc2Detector,
149-
awsEcsDetector,
150-
awsEksDetector,
148+
awsEc2DetectorSync,
149+
awsEcsDetectorSync,
150+
awsEksDetectorSync,
151151
envDetectorSync,
152152
];
153153
}

0 commit comments

Comments
 (0)