Skip to content

Commit db8245a

Browse files
authored
refactor(resource-detector-aws): migrate away from getEnv() (open-telemetry#2706)
1 parent 7a1e8b3 commit db8245a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import * as http from 'http';
4848
import * as util from 'util';
4949
import * as fs from 'fs';
5050
import * as os from 'os';
51-
import { getEnv } from '@opentelemetry/core';
5251

5352
const HTTP_TIMEOUT_IN_MS = 1000;
5453

@@ -77,8 +76,10 @@ export class AwsEcsDetectorSync implements DetectorSync {
7776
}
7877

7978
private async _getAttributes(): Promise<ResourceAttributes> {
80-
const env = getEnv();
81-
if (!env.ECS_CONTAINER_METADATA_URI_V4 && !env.ECS_CONTAINER_METADATA_URI) {
79+
if (
80+
!process.env.ECS_CONTAINER_METADATA_URI_V4 &&
81+
!process.env.ECS_CONTAINER_METADATA_URI
82+
) {
8283
diag.debug('AwsEcsDetector failed: Process is not on ECS');
8384
return {};
8485
}
@@ -89,7 +90,7 @@ export class AwsEcsDetectorSync implements DetectorSync {
8990
[ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AWS_ECS,
9091
}).merge(await AwsEcsDetectorSync._getContainerIdAndHostnameResource());
9192

92-
const metadataUrl = getEnv().ECS_CONTAINER_METADATA_URI_V4;
93+
const metadataUrl = process.env.ECS_CONTAINER_METADATA_URI_V4;
9394
if (metadataUrl) {
9495
const [containerMetadata, taskMetadata] = await Promise.all([
9596
AwsEcsDetectorSync._getUrlAsJson(metadataUrl),

0 commit comments

Comments
 (0)