Skip to content

Commit

Permalink
use sync resource detectors (#112)
Browse files Browse the repository at this point in the history
*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.
  • Loading branch information
pxaws authored Oct 30, 2024
1 parent b6d2752 commit 59d1adb
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { OTLPTraceExporter as OTLPProtoTraceExporter } from '@opentelemetry/expo
import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
import { AWSXRayIdGenerator } from '@opentelemetry/id-generator-aws-xray';
import { Instrumentation } from '@opentelemetry/instrumentation';
import { awsEc2Detector, awsEcsDetector, awsEksDetector } from '@opentelemetry/resource-detector-aws';
import { awsEc2DetectorSync, awsEcsDetectorSync, awsEksDetectorSync } from '@opentelemetry/resource-detector-aws';
import {
Detector,
DetectorSync,
Expand Down Expand Up @@ -126,7 +126,7 @@ export class AwsOpentelemetryConfigurator {
// Add Env/AWS Resource Detectors if not present
const resourceDetectorsFromEnv: string[] = process.env.OTEL_NODE_RESOURCE_DETECTORS.split(',');
if (!resourceDetectorsFromEnv.includes('aws')) {
defaultDetectors.push(awsEc2Detector, awsEcsDetector, awsEksDetector);
defaultDetectors.push(awsEc2DetectorSync, awsEcsDetectorSync, awsEksDetectorSync);
}
if (!resourceDetectorsFromEnv.includes('env')) {
defaultDetectors.push(envDetectorSync);
Expand All @@ -145,9 +145,9 @@ export class AwsOpentelemetryConfigurator {
defaultDetectors = [
processDetector,
hostDetector,
awsEc2Detector,
awsEcsDetector,
awsEksDetector,
awsEc2DetectorSync,
awsEcsDetectorSync,
awsEksDetectorSync,
envDetectorSync,
];
}
Expand Down

0 comments on commit 59d1adb

Please sign in to comment.