|
19 | 19 | from urllib.error import URLError
|
20 | 20 |
|
21 | 21 | 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 | +) |
23 | 27 |
|
24 | 28 |
|
25 | 29 | # TODO: Remove when cloud resource id is no longer missing in Resource Attributes
|
26 |
| -_CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE = "cloud.resource_id" |
27 | 30 | _AZURE_VM_METADATA_ENDPOINT = "http://169.254.169.254/metadata/instance/compute?api-version=2021-12-13&format=json"
|
28 | 31 | _AZURE_VM_SCALE_SET_NAME_ATTRIBUTE = "azure.vm.scaleset.name"
|
29 | 32 | _AZURE_VM_SKU_ATTRIBUTE = "azure.vm.sku"
|
|
35 | 38 | ResourceAttributes.CLOUD_PLATFORM,
|
36 | 39 | ResourceAttributes.CLOUD_PROVIDER,
|
37 | 40 | ResourceAttributes.CLOUD_REGION,
|
38 |
| - _CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE, |
| 41 | + ResourceAttributes.CLOUD_RESOURCE_ID, |
39 | 42 | ResourceAttributes.HOST_ID,
|
40 | 43 | ResourceAttributes.HOST_NAME,
|
41 | 44 | ResourceAttributes.HOST_TYPE,
|
@@ -81,7 +84,7 @@ def get_attribute_from_metadata(self, metadata_json, attribute_key):
|
81 | 84 | ams_value = CloudProviderValues.AZURE.value
|
82 | 85 | elif attribute_key == ResourceAttributes.CLOUD_REGION:
|
83 | 86 | ams_value = metadata_json["location"]
|
84 |
| - elif attribute_key == _CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE: |
| 87 | + elif attribute_key == ResourceAttributes.CLOUD_RESOURCE_ID: |
85 | 88 | ams_value = metadata_json["resourceId"]
|
86 | 89 | elif attribute_key == ResourceAttributes.HOST_ID or \
|
87 | 90 | attribute_key == ResourceAttributes.SERVICE_INSTANCE_ID:
|
|
0 commit comments