Skip to content

Commit c4c72e2

Browse files
committed
Using new cloud resource id attribute
1 parent e318c94 commit c4c72e2

File tree

2 files changed

+8
-7
lines changed
  • resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure

2 files changed

+8
-7
lines changed

resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/app_service.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
from opentelemetry.semconv.resource import ResourceAttributes, CloudPlatformValues, CloudProviderValues
1919

2020
_AZURE_APP_SERVICE_STAMP_RESOURCE_ATTRIBUTE = "azure.app.service.stamp"
21-
# TODO: Remove once this resource attribute is no longer missing from SDK
22-
_CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE = "cloud.resource_id"
2321
_REGION_NAME = "REGION_NAME"
2422
_WEBSITE_HOME_STAMPNAME = "WEBSITE_HOME_STAMPNAME"
2523
_WEBSITE_HOSTNAME = "WEBSITE_HOSTNAME"
@@ -49,7 +47,7 @@ def detect(self) -> Resource:
4947

5048
azure_resource_uri = _get_azure_resource_uri(website_site_name)
5149
if azure_resource_uri:
52-
attributes[_CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE] = azure_resource_uri
50+
attributes[ResourceAttributes.CLOUD_RESOURCE_ID] = azure_resource_uri
5351
for (key, env_var) in _APP_SERVICE_ATTRIBUTE_ENV_VARS.items():
5452
value = environ.get(env_var)
5553
if value:

resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/vm.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
from urllib.error import URLError
2020

2121
from opentelemetry.sdk.resources import ResourceDetector, Resource
22-
from opentelemetry.semconv.resource import ResourceAttributes, CloudPlatformValues, CloudProviderValues
22+
from opentelemetry.semconv.resource import (
23+
ResourceAttributes,
24+
CloudPlatformValues,
25+
CloudProviderValues,
26+
)
2327

2428

2529
# TODO: Remove when cloud resource id is no longer missing in Resource Attributes
26-
_CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE = "cloud.resource_id"
2730
_AZURE_VM_METADATA_ENDPOINT = "http://169.254.169.254/metadata/instance/compute?api-version=2021-12-13&format=json"
2831
_AZURE_VM_SCALE_SET_NAME_ATTRIBUTE = "azure.vm.scaleset.name"
2932
_AZURE_VM_SKU_ATTRIBUTE = "azure.vm.sku"
@@ -35,7 +38,7 @@
3538
ResourceAttributes.CLOUD_PLATFORM,
3639
ResourceAttributes.CLOUD_PROVIDER,
3740
ResourceAttributes.CLOUD_REGION,
38-
_CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,
41+
ResourceAttributes.CLOUD_RESOURCE_ID,
3942
ResourceAttributes.HOST_ID,
4043
ResourceAttributes.HOST_NAME,
4144
ResourceAttributes.HOST_TYPE,
@@ -81,7 +84,7 @@ def get_attribute_from_metadata(self, metadata_json, attribute_key):
8184
ams_value = CloudProviderValues.AZURE.value
8285
elif attribute_key == ResourceAttributes.CLOUD_REGION:
8386
ams_value = metadata_json["location"]
84-
elif attribute_key == _CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE:
87+
elif attribute_key == ResourceAttributes.CLOUD_RESOURCE_ID:
8588
ams_value = metadata_json["resourceId"]
8689
elif attribute_key == ResourceAttributes.HOST_ID or \
8790
attribute_key == ResourceAttributes.SERVICE_INSTANCE_ID:

0 commit comments

Comments
 (0)