Skip to content

Commit 8e1ca48

Browse files
authored
feat(resource-detector-azure)!: update semconv usage to ATTR_ exports, update to semconv v1.37.0 (#3063)
1 parent d546c4d commit 8e1ca48

File tree

9 files changed

+322
-122
lines changed

9 files changed

+322
-122
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/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"dependencies": {
5757
"@opentelemetry/core": "^2.0.0",
5858
"@opentelemetry/resources": "^2.0.0",
59-
"@opentelemetry/semantic-conventions": "^1.27.0"
59+
"@opentelemetry/semantic-conventions": "^1.37.0"
6060
},
6161
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/resource-detector-azure#readme",
6262
"sideEffects": false

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 '../semconv';
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 '../semconv';
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 '../semconv';
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) {

0 commit comments

Comments
 (0)