diff --git a/packages/opentelemetry-resources/src/platform/node/detectors/AwsEc2Detector.ts b/packages/opentelemetry-resources/src/platform/node/detectors/AwsEc2Detector.ts index d3317b9c09..7e68016925 100644 --- a/packages/opentelemetry-resources/src/platform/node/detectors/AwsEc2Detector.ts +++ b/packages/opentelemetry-resources/src/platform/node/detectors/AwsEc2Detector.ts @@ -44,13 +44,17 @@ class AwsEc2Detector implements Detector { const { accountId, instanceId, + instanceType, region, + availabilityZone, } = await this._awsMetadataAccessor(); return new Resource({ [CLOUD_RESOURCE.PROVIDER]: 'aws', [CLOUD_RESOURCE.ACCOUNT_ID]: accountId, [CLOUD_RESOURCE.REGION]: region, + [CLOUD_RESOURCE.ZONE]: availabilityZone, [HOST_RESOURCE.ID]: instanceId, + [HOST_RESOURCE.TYPE]: instanceType, }); } catch { return Resource.empty(); diff --git a/packages/opentelemetry-resources/test/detect-resources.test.ts b/packages/opentelemetry-resources/test/detect-resources.test.ts index 24efdf7638..583aa48b3a 100644 --- a/packages/opentelemetry-resources/test/detect-resources.test.ts +++ b/packages/opentelemetry-resources/test/detect-resources.test.ts @@ -48,8 +48,10 @@ const { origin: AWS_HOST, pathname: AWS_PATH } = new URL( const mockedAwsResponse = { instanceId: 'my-instance-id', + instanceType: 'my-instance-type', accountId: 'my-account-id', region: 'my-region', + availabilityZone: 'my-zone', }; describe('detectResources', async () => { @@ -132,8 +134,12 @@ describe('detectResources', async () => { provider: 'aws', accountId: 'my-account-id', region: 'my-region', + zone: 'my-zone', + }); + assertHostResource(resource, { + id: 'my-instance-id', + hostType: 'my-instance-type', }); - assertHostResource(resource, { id: 'my-instance-id' }); assertServiceResource(resource, { instanceId: '627cc493', name: 'my-service', diff --git a/packages/opentelemetry-resources/test/detectors/AwsEc2Detector.test.ts b/packages/opentelemetry-resources/test/detectors/AwsEc2Detector.test.ts index 6777d472fe..93e53296d2 100644 --- a/packages/opentelemetry-resources/test/detectors/AwsEc2Detector.test.ts +++ b/packages/opentelemetry-resources/test/detectors/AwsEc2Detector.test.ts @@ -31,8 +31,10 @@ const { origin: AWS_HOST, pathname: AWS_PATH } = new URL( const mockedAwsResponse = { instanceId: 'my-instance-id', + instanceType: 'my-instance-type', accountId: 'my-account-id', region: 'my-region', + availabilityZone: 'my-zone', }; describe('awsEc2Detector', () => { @@ -58,9 +60,11 @@ describe('awsEc2Detector', () => { provider: 'aws', accountId: 'my-account-id', region: 'my-region', + zone: 'my-zone', }); assertHostResource(resource, { id: 'my-instance-id', + hostType: 'my-instance-type', }); }); });