Skip to content

Commit

Permalink
chore(opentelemetry-resources): add instance type and az to aws detector
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Walz <justin.walz10@gmail.com>
  • Loading branch information
justinwalz committed May 14, 2020
1 parent 7ccf1d0 commit 70242cf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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',
});
});
});
Expand Down

0 comments on commit 70242cf

Please sign in to comment.