Skip to content

Commit 9b37843

Browse files
committed
chore(resource-detector-azure)!: update semconv usage to ATTR_ exports
BREAKING CHANGE: This also updates the Semantic Conventions of the emitted resource attributes from v1.19.0 to v1.37.0 which involves these breaking changes: - App Service resource detector: `deployment.environment` -> `deployment.environment.name` This changed in semconv v1.27.0 as part of open-telemetry/semantic-conventions#1075 - Semconv v1.35.0 naming convention changes (https://github.com/open-telemetry/semantic-conventions/blob/main/CHANGELOG.md#v1350) resulted in a change in the name of some `cloud.platform` values: - `azure_app_service` -> `azure.app_service` - `azure_vm` -> `azure.vm` - `azure_functions` -> `azure.functions` Refs: #2377
1 parent 9d0371b commit 9b37843

File tree

7 files changed

+112
-121
lines changed

7 files changed

+112
-121
lines changed

packages/resource-detector-azure/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ const tracerProvider = new NodeTracerProvider({ resource });
2727

2828
## Available Detectors
2929

30-
This package implements Semantic Convention [Version 1.19.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.19.0/semantic_conventions/README.md).
30+
This package implements Semantic Convention [Version 1.37.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.37.0/semantic_conventions/README.md).
3131

3232
### App Service Resource Detector
3333

3434
| Resource Attribute | Description |
3535
|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
3636
| azure.app.service.stamp | The specific "stamp" cluster within Azure where the App Service is running, e.g., "waws-prod-sn1-001". Value of Process Environment Variable `APP_SERVICE_ATTRIBUTE_ENV_VARS`. |
37-
| cloud.platform | The cloud platform. Here, it's always "azure_app_service". |
37+
| cloud.platform | The cloud platform. Here, it's always "azure.app_service". |
3838
| cloud.provider | The cloud service provider. In this context, it's always "azure". |
3939
| cloud.region | The Azure region where the App Service is hosted, e.g., "East US", "West Europe", etc. Value of Process Environment Variable `REGION_NAME`. |
4040
| cloud.resource_id | The Azure Resource Manager URI uniquely identifying the Azure App Service. Typically in the format `/subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Web/sites/{siteName}`. |
41-
| deployment.environment | The deployment slot where the Azure App Service is running, such as "staging", "production", etc. Value of Process Environment Variable `WEBSITE_SLOT_NAME`. |
41+
| deployment.environment.name | The deployment slot where the Azure App Service is running, such as "staging", "production", etc. Value of Process Environment Variable `WEBSITE_SLOT_NAME`. |
4242
| host.id | The primary hostname for the app, excluding any custom hostnames. Value of Process Environment Variable `WEBSITE_HOSTNAME`. |
4343
| service.instance.id | The specific instance of the Azure App Service, useful in a scaled-out configuration. Value of Process Environment Variable `WEBSITE_INSTANCE_ID`. |
4444
| service.name | The name of the Azure App Service. Value of Process Environment Variable `WEBSITE_SITE_NAME`. |
@@ -49,7 +49,7 @@ This package implements Semantic Convention [Version 1.19.0](https://github.com/
4949
|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
5050
| azure.vm.scaleset.name | The name of the Virtual Machine Scale Set if the VM is part of one. Value from `vmScaleSetName` key on `/metadata/instance/compute` request. |
5151
| azure.vm.sku | The SKU of the Azure Virtual Machine's operating system. For instance, for a VM running Windows Server 2019 Datacenter edition, this value would be "2019-Datacenter". Value from `sku` key on `/metadata/instance/compute` request. |
52-
| cloud.platform | The cloud platform, which is always set to "azure_vm" in this context. |
52+
| cloud.platform | The cloud platform, which is always set to "azure.vm" in this context. |
5353
| cloud.provider | The cloud service provider, which is always set to "azure" in this context. |
5454
| cloud.region | The Azure region where the Virtual Machine is hosted, such as "East US", "West Europe", etc. Value from `location` key on `/metadata/instance/compute` request. |
5555
| cloud.resource_id | The Azure Resource Manager URI uniquely identifying the Azure Virtual Machine. It typically follows this format: `/subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Compute/virtualMachines/{vmName}`. Value from `resourceId` key on `/metadata/instance/compute` request.|
@@ -62,7 +62,7 @@ This package implements Semantic Convention [Version 1.19.0](https://github.com/
6262

6363
| Resource Attribute | Description |
6464
|-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
65-
| cloud.platform | The cloud platform. Here, it's always "azure_functions". |
65+
| cloud.platform | The cloud platform. Here, it's always "azure.functions". |
6666
| cloud.provider | The cloud service provider. In this context, it's always "azure". |
6767
| cloud.region | The Azure region where the Azure Function is hosted, e.g., "East US", "West Europe", etc. Value of Process Environment Variable `REGION_NAME`. |
6868
| faas.instance | The specific instance of the Azure App Service, useful in a scaled-out configuration. Value from Process Environment Variable `WEBSITE_INSTANCE_ID`. |

packages/resource-detector-azure/src/detectors/AzureAppServiceDetector.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,24 @@ import {
2525
WEBSITE_SLOT_NAME,
2626
CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,
2727
} from '../types';
28+
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
2829
import {
29-
SEMRESATTRS_CLOUD_REGION,
30-
SEMRESATTRS_DEPLOYMENT_ENVIRONMENT,
31-
SEMRESATTRS_HOST_ID,
32-
SEMRESATTRS_SERVICE_INSTANCE_ID,
33-
SEMRESATTRS_SERVICE_NAME,
34-
SEMRESATTRS_CLOUD_PROVIDER,
35-
SEMRESATTRS_CLOUD_PLATFORM,
36-
CLOUDPROVIDERVALUES_AZURE,
37-
CLOUDPLATFORMVALUES_AZURE_APP_SERVICE,
38-
} from '@opentelemetry/semantic-conventions';
30+
ATTR_CLOUD_REGION,
31+
ATTR_DEPLOYMENT_ENVIRONMENT_NAME,
32+
ATTR_HOST_ID,
33+
ATTR_SERVICE_INSTANCE_ID,
34+
ATTR_CLOUD_PROVIDER,
35+
CLOUD_PROVIDER_VALUE_AZURE,
36+
ATTR_CLOUD_PLATFORM,
37+
CLOUD_PLATFORM_VALUE_AZURE_APP_SERVICE,
38+
} from '@opentelemetry/semantic-conventions/incubating';
3939
import { getAzureResourceUri, isAzureFunction } from '../utils';
4040

4141
const APP_SERVICE_ATTRIBUTE_ENV_VARS = {
42-
[SEMRESATTRS_CLOUD_REGION]: REGION_NAME,
43-
[SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]: WEBSITE_SLOT_NAME,
44-
[SEMRESATTRS_HOST_ID]: WEBSITE_HOSTNAME,
45-
[SEMRESATTRS_SERVICE_INSTANCE_ID]: WEBSITE_INSTANCE_ID,
42+
[ATTR_CLOUD_REGION]: REGION_NAME,
43+
[ATTR_DEPLOYMENT_ENVIRONMENT_NAME]: WEBSITE_SLOT_NAME,
44+
[ATTR_HOST_ID]: WEBSITE_HOSTNAME,
45+
[ATTR_SERVICE_INSTANCE_ID]: WEBSITE_INSTANCE_ID,
4646
[AZURE_APP_SERVICE_STAMP_RESOURCE_ATTRIBUTE]: WEBSITE_HOME_STAMPNAME,
4747
};
4848

@@ -57,15 +57,15 @@ class AzureAppServiceDetector implements ResourceDetector {
5757
if (websiteSiteName && !isAzureFunction()) {
5858
attributes = {
5959
...attributes,
60-
[SEMRESATTRS_SERVICE_NAME]: websiteSiteName,
60+
[ATTR_SERVICE_NAME]: websiteSiteName,
6161
};
6262
attributes = {
6363
...attributes,
64-
[SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_AZURE,
64+
[ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_AZURE,
6565
};
6666
attributes = {
6767
...attributes,
68-
[SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_AZURE_APP_SERVICE,
68+
[ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AZURE_APP_SERVICE,
6969
};
7070

7171
const azureResourceUri = getAzureResourceUri(websiteSiteName);

packages/resource-detector-azure/src/detectors/AzureFunctionsDetector.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
*/
1616

1717
import { ResourceDetector, DetectedResource } from '@opentelemetry/resources';
18+
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
1819
import {
19-
SEMRESATTRS_FAAS_MAX_MEMORY,
20-
SEMRESATTRS_FAAS_INSTANCE,
21-
SEMRESATTRS_CLOUD_PROVIDER,
22-
SEMRESATTRS_CLOUD_PLATFORM,
23-
SEMRESATTRS_CLOUD_REGION,
24-
CLOUDPROVIDERVALUES_AZURE,
25-
CLOUDPLATFORMVALUES_AZURE_FUNCTIONS,
26-
SEMRESATTRS_SERVICE_NAME,
27-
SEMRESATTRS_PROCESS_PID,
28-
} from '@opentelemetry/semantic-conventions';
20+
ATTR_FAAS_MAX_MEMORY,
21+
ATTR_FAAS_INSTANCE,
22+
ATTR_CLOUD_PROVIDER,
23+
CLOUD_PROVIDER_VALUE_AZURE,
24+
ATTR_CLOUD_PLATFORM,
25+
CLOUD_PLATFORM_VALUE_AZURE_FUNCTIONS,
26+
ATTR_CLOUD_REGION,
27+
ATTR_PROCESS_PID,
28+
} from '@opentelemetry/semantic-conventions/incubating';
2929
import {
3030
WEBSITE_SITE_NAME,
3131
WEBSITE_INSTANCE_ID,
@@ -36,9 +36,9 @@ import {
3636
import { getAzureResourceUri, isAzureFunction } from '../utils';
3737

3838
const AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS = {
39-
[SEMRESATTRS_SERVICE_NAME]: WEBSITE_SITE_NAME,
40-
[SEMRESATTRS_FAAS_INSTANCE]: WEBSITE_INSTANCE_ID,
41-
[SEMRESATTRS_FAAS_MAX_MEMORY]: FUNCTIONS_MEM_LIMIT,
39+
[ATTR_SERVICE_NAME]: WEBSITE_SITE_NAME,
40+
[ATTR_FAAS_INSTANCE]: WEBSITE_INSTANCE_ID,
41+
[ATTR_FAAS_MAX_MEMORY]: FUNCTIONS_MEM_LIMIT,
4242
};
4343

4444
/**
@@ -60,28 +60,28 @@ class AzureFunctionsDetector implements ResourceDetector {
6060
const functionMemLimit = process.env[FUNCTIONS_MEM_LIMIT];
6161

6262
attributes = {
63-
[SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_AZURE,
64-
[SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_AZURE_FUNCTIONS,
65-
[SEMRESATTRS_CLOUD_REGION]: process.env[REGION_NAME],
66-
[SEMRESATTRS_PROCESS_PID]: process.pid,
63+
[ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_AZURE,
64+
[ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AZURE_FUNCTIONS,
65+
[ATTR_CLOUD_REGION]: process.env[REGION_NAME],
66+
[ATTR_PROCESS_PID]: process.pid,
6767
};
6868

6969
if (serviceName) {
7070
attributes = {
7171
...attributes,
72-
[SEMRESATTRS_SERVICE_NAME]: serviceName,
72+
[ATTR_SERVICE_NAME]: serviceName,
7373
};
7474
}
7575
if (functionInstance) {
7676
attributes = {
7777
...attributes,
78-
[SEMRESATTRS_FAAS_INSTANCE]: functionInstance,
78+
[ATTR_FAAS_INSTANCE]: functionInstance,
7979
};
8080
}
8181
if (functionMemLimit) {
8282
attributes = {
8383
...attributes,
84-
[SEMRESATTRS_FAAS_MAX_MEMORY]: functionMemLimit,
84+
[ATTR_FAAS_MAX_MEMORY]: functionMemLimit,
8585
};
8686
}
8787
const azureResourceUri = getAzureResourceUri(serviceName);

packages/resource-detector-azure/src/detectors/AzureVmDetector.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ import {
2424
DetectedResourceAttributes,
2525
} from '@opentelemetry/resources';
2626
import {
27-
CLOUDPLATFORMVALUES_AZURE_VM,
28-
CLOUDPROVIDERVALUES_AZURE,
29-
SEMRESATTRS_CLOUD_PLATFORM,
30-
SEMRESATTRS_CLOUD_PROVIDER,
31-
SEMRESATTRS_CLOUD_REGION,
32-
SEMRESATTRS_HOST_ID,
33-
SEMRESATTRS_HOST_NAME,
34-
SEMRESATTRS_HOST_TYPE,
35-
SEMRESATTRS_OS_VERSION,
36-
} from '@opentelemetry/semantic-conventions';
27+
ATTR_CLOUD_PLATFORM,
28+
CLOUD_PLATFORM_VALUE_AZURE_VM,
29+
ATTR_CLOUD_PROVIDER,
30+
CLOUD_PROVIDER_VALUE_AZURE,
31+
ATTR_CLOUD_REGION,
32+
ATTR_HOST_ID,
33+
ATTR_HOST_NAME,
34+
ATTR_HOST_TYPE,
35+
ATTR_OS_VERSION,
36+
} from '@opentelemetry/semantic-conventions/incubating';
3737
import {
3838
CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,
3939
AZURE_VM_METADATA_HOST,
@@ -56,14 +56,14 @@ class AzureVmResourceDetector implements ResourceDetector {
5656
const attrNames = [
5757
AZURE_VM_SCALE_SET_NAME_ATTRIBUTE,
5858
AZURE_VM_SKU_ATTRIBUTE,
59-
SEMRESATTRS_CLOUD_PLATFORM,
60-
SEMRESATTRS_CLOUD_PROVIDER,
61-
SEMRESATTRS_CLOUD_REGION,
59+
ATTR_CLOUD_PLATFORM,
60+
ATTR_CLOUD_PROVIDER,
61+
ATTR_CLOUD_REGION,
6262
CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,
63-
SEMRESATTRS_HOST_ID,
64-
SEMRESATTRS_HOST_NAME,
65-
SEMRESATTRS_HOST_TYPE,
66-
SEMRESATTRS_OS_VERSION,
63+
ATTR_HOST_ID,
64+
ATTR_HOST_NAME,
65+
ATTR_HOST_TYPE,
66+
ATTR_OS_VERSION,
6767
];
6868

6969
const attributes = {} as DetectedResourceAttributes;
@@ -122,14 +122,14 @@ class AzureVmResourceDetector implements ResourceDetector {
122122
const attributes = {
123123
[AZURE_VM_SCALE_SET_NAME_ATTRIBUTE]: metadata['vmScaleSetName'],
124124
[AZURE_VM_SKU_ATTRIBUTE]: metadata['sku'],
125-
[SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_AZURE_VM,
126-
[SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_AZURE,
127-
[SEMRESATTRS_CLOUD_REGION]: metadata['location'],
125+
[ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AZURE_VM,
126+
[ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_AZURE,
127+
[ATTR_CLOUD_REGION]: metadata['location'],
128128
[CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE]: metadata['resourceId'],
129-
[SEMRESATTRS_HOST_ID]: metadata['vmId'],
130-
[SEMRESATTRS_HOST_NAME]: metadata['name'],
131-
[SEMRESATTRS_HOST_TYPE]: metadata['vmSize'],
132-
[SEMRESATTRS_OS_VERSION]: metadata['version'],
129+
[ATTR_HOST_ID]: metadata['vmId'],
130+
[ATTR_HOST_NAME]: metadata['name'],
131+
[ATTR_HOST_TYPE]: metadata['vmSize'],
132+
[ATTR_OS_VERSION]: metadata['version'],
133133
};
134134
return attributes;
135135
} catch (err: any) {

packages/resource-detector-azure/test/detectors/AzureAppServiceDetector.test.ts

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
import * as assert from 'assert';
1818
import { azureAppServiceDetector } from '../../src/detectors/AzureAppServiceDetector';
19+
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
1920
import {
20-
SEMRESATTRS_CLOUD_PLATFORM,
21-
SEMRESATTRS_CLOUD_PROVIDER,
22-
SEMRESATTRS_CLOUD_REGION,
23-
SEMRESATTRS_DEPLOYMENT_ENVIRONMENT,
24-
SEMRESATTRS_HOST_ID,
25-
SEMRESATTRS_SERVICE_INSTANCE_ID,
26-
SEMRESATTRS_SERVICE_NAME,
27-
} from '@opentelemetry/semantic-conventions';
21+
ATTR_CLOUD_PLATFORM,
22+
ATTR_CLOUD_PROVIDER,
23+
ATTR_CLOUD_REGION,
24+
ATTR_DEPLOYMENT_ENVIRONMENT_NAME,
25+
ATTR_HOST_ID,
26+
ATTR_SERVICE_INSTANCE_ID,
27+
} from '@opentelemetry/semantic-conventions/incubating';
2828
import { azureFunctionsDetector } from '../../src';
2929
import { detectResources } from '@opentelemetry/resources';
3030

@@ -53,24 +53,21 @@ describe('AzureAppServiceDetector', () => {
5353
});
5454
assert.ok(resource);
5555
const attributes = resource.attributes;
56-
assert.strictEqual(attributes[SEMRESATTRS_SERVICE_NAME], 'test-site');
57-
assert.strictEqual(attributes[SEMRESATTRS_CLOUD_PROVIDER], 'azure');
58-
assert.strictEqual(
59-
attributes[SEMRESATTRS_CLOUD_PLATFORM],
60-
'azure_app_service'
61-
);
56+
assert.strictEqual(attributes[ATTR_SERVICE_NAME], 'test-site');
57+
assert.strictEqual(attributes[ATTR_CLOUD_PROVIDER], 'azure');
58+
assert.strictEqual(attributes[ATTR_CLOUD_PLATFORM], 'azure.app_service');
6259
assert.strictEqual(
6360
attributes['cloud.resource_id'],
6461
`/subscriptions/${process.env.WEBSITE_OWNER_NAME}/resourceGroups/${process.env.WEBSITE_RESOURCE_GROUP}/providers/Microsoft.Web/sites/${process.env.WEBSITE_SITE_NAME}`
6562
);
66-
assert.strictEqual(attributes[SEMRESATTRS_CLOUD_REGION], 'test-region');
63+
assert.strictEqual(attributes[ATTR_CLOUD_REGION], 'test-region');
6764
assert.strictEqual(
68-
attributes[SEMRESATTRS_DEPLOYMENT_ENVIRONMENT],
65+
attributes[ATTR_DEPLOYMENT_ENVIRONMENT_NAME],
6966
'test-slot'
7067
);
71-
assert.strictEqual(attributes[SEMRESATTRS_HOST_ID], 'test-hostname');
68+
assert.strictEqual(attributes[ATTR_HOST_ID], 'test-hostname');
7269
assert.strictEqual(
73-
attributes[SEMRESATTRS_SERVICE_INSTANCE_ID],
70+
attributes[ATTR_SERVICE_INSTANCE_ID],
7471
'test-instance-id'
7572
);
7673
assert.strictEqual(
@@ -93,14 +90,14 @@ describe('AzureAppServiceDetector', () => {
9390
});
9491
assert.ok(resource);
9592
const attributes = resource.attributes;
96-
assert.strictEqual(attributes[SEMRESATTRS_CLOUD_REGION], 'test-region');
93+
assert.strictEqual(attributes[ATTR_CLOUD_REGION], 'test-region');
9794
assert.strictEqual(
98-
attributes[SEMRESATTRS_DEPLOYMENT_ENVIRONMENT],
95+
attributes[ATTR_DEPLOYMENT_ENVIRONMENT_NAME],
9996
'test-slot'
10097
);
101-
assert.strictEqual(attributes[SEMRESATTRS_HOST_ID], 'test-hostname');
98+
assert.strictEqual(attributes[ATTR_HOST_ID], 'test-hostname');
10299
assert.strictEqual(
103-
attributes[SEMRESATTRS_SERVICE_INSTANCE_ID],
100+
attributes[ATTR_SERVICE_INSTANCE_ID],
104101
'test-instance-id'
105102
);
106103
assert.strictEqual(
@@ -124,14 +121,14 @@ describe('AzureAppServiceDetector', () => {
124121
});
125122
assert.ok(resource);
126123
const attributes = resource.attributes;
127-
assert.strictEqual(attributes[SEMRESATTRS_CLOUD_REGION], 'test-region');
124+
assert.strictEqual(attributes[ATTR_CLOUD_REGION], 'test-region');
128125
assert.strictEqual(
129-
attributes[SEMRESATTRS_DEPLOYMENT_ENVIRONMENT],
126+
attributes[ATTR_DEPLOYMENT_ENVIRONMENT_NAME],
130127
'test-slot'
131128
);
132-
assert.strictEqual(attributes[SEMRESATTRS_HOST_ID], 'test-hostname');
129+
assert.strictEqual(attributes[ATTR_HOST_ID], 'test-hostname');
133130
assert.strictEqual(
134-
attributes[SEMRESATTRS_SERVICE_INSTANCE_ID],
131+
attributes[ATTR_SERVICE_INSTANCE_ID],
135132
'test-instance-id'
136133
);
137134
assert.strictEqual(

0 commit comments

Comments
 (0)