Skip to content

Commit 35e6607

Browse files
chore(resource-detector-alibaba): use exported strings for attributes (#2046)
Use exported strings for Semantic Resource Attributes, Cloud Platform Values and Cloud Provider Values. Signed-off-by: maryliag <marylia.gutierrez@grafana.com> Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
1 parent 70090c1 commit 35e6607

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

detectors/node/opentelemetry-resource-detector-alibaba-cloud/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
},
5858
"dependencies": {
5959
"@opentelemetry/resources": "^1.0.0",
60-
"@opentelemetry/semantic-conventions": "^1.0.0"
60+
"@opentelemetry/semantic-conventions": "^1.22.0"
6161
},
6262
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-alibaba-cloud#readme"
6363
}

detectors/node/opentelemetry-resource-detector-alibaba-cloud/src/detectors/AlibabaCloudEcsDetector.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ import {
2020
ResourceDetectionConfig,
2121
} from '@opentelemetry/resources';
2222
import {
23-
CloudPlatformValues,
24-
CloudProviderValues,
25-
SemanticResourceAttributes,
23+
CLOUDPLATFORMVALUES_ALIBABA_CLOUD_ECS,
24+
CLOUDPROVIDERVALUES_ALIBABA_CLOUD,
25+
SEMRESATTRS_CLOUD_ACCOUNT_ID,
26+
SEMRESATTRS_CLOUD_AVAILABILITY_ZONE,
27+
SEMRESATTRS_CLOUD_PLATFORM,
28+
SEMRESATTRS_CLOUD_PROVIDER,
29+
SEMRESATTRS_CLOUD_REGION,
30+
SEMRESATTRS_HOST_ID,
31+
SEMRESATTRS_HOST_NAME,
32+
SEMRESATTRS_HOST_TYPE,
2633
} from '@opentelemetry/semantic-conventions';
2734
import * as http from 'http';
2835

@@ -61,16 +68,14 @@ class AlibabaCloudEcsDetector implements Detector {
6168
const hostname = await this._fetchHost();
6269

6370
return new Resource({
64-
[SemanticResourceAttributes.CLOUD_PROVIDER]:
65-
CloudProviderValues.ALIBABA_CLOUD,
66-
[SemanticResourceAttributes.CLOUD_PLATFORM]:
67-
CloudPlatformValues.ALIBABA_CLOUD_ECS,
68-
[SemanticResourceAttributes.CLOUD_ACCOUNT_ID]: accountId,
69-
[SemanticResourceAttributes.CLOUD_REGION]: region,
70-
[SemanticResourceAttributes.CLOUD_AVAILABILITY_ZONE]: availabilityZone,
71-
[SemanticResourceAttributes.HOST_ID]: instanceId,
72-
[SemanticResourceAttributes.HOST_TYPE]: instanceType,
73-
[SemanticResourceAttributes.HOST_NAME]: hostname,
71+
[SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_ALIBABA_CLOUD,
72+
[SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_ALIBABA_CLOUD_ECS,
73+
[SEMRESATTRS_CLOUD_ACCOUNT_ID]: accountId,
74+
[SEMRESATTRS_CLOUD_REGION]: region,
75+
[SEMRESATTRS_CLOUD_AVAILABILITY_ZONE]: availabilityZone,
76+
[SEMRESATTRS_HOST_ID]: instanceId,
77+
[SEMRESATTRS_HOST_TYPE]: instanceType,
78+
[SEMRESATTRS_HOST_NAME]: hostname,
7479
});
7580
}
7681

detectors/node/opentelemetry-resource-detector-alibaba-cloud/test/detectors/AlibabaCloudEcsDetector.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import * as nock from 'nock';
1818
import * as assert from 'assert';
1919
import { Resource } from '@opentelemetry/resources';
20-
import { CloudProviderValues } from '@opentelemetry/semantic-conventions';
20+
import { CLOUDPROVIDERVALUES_ALIBABA_CLOUD } from '@opentelemetry/semantic-conventions';
2121
import { alibabaCloudEcsDetector } from '../../src';
2222
import {
2323
assertCloudResource,
@@ -70,7 +70,7 @@ describe('alibabaCloudEcsDetector', () => {
7070
assert.ok(resource);
7171

7272
assertCloudResource(resource, {
73-
provider: CloudProviderValues.ALIBABA_CLOUD,
73+
provider: CLOUDPROVIDERVALUES_ALIBABA_CLOUD,
7474
accountId: 'my-owner-account-id',
7575
region: 'my-region-id',
7676
zone: 'my-zone-id',

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)