From 5f80baf22ed1365f920373dc9a759185b2664309 Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Wed, 21 Feb 2024 10:10:38 -0800 Subject: [PATCH 1/2] ver --- .../azure-monitor-opentelemetry-exporter/CHANGELOG.md | 2 ++ .../azure/monitor/opentelemetry/exporter/_utils.py | 4 ++++ .../tests/test_utils.py | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md b/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md index 205e66e7b860..9b6c1d998825 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md @@ -6,6 +6,8 @@ - Add device.* to part A fields ([#34229](https://github.com/Azure/azure-sdk-for-python/pull/34229)) +- Add application.ver to part A fields + ([#34229](https://github.com/Azure/azure-sdk-for-python/pull/34229)) ### Breaking Changes diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py index 8aecae9bba05..01078adb19d9 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py @@ -182,6 +182,7 @@ def _populate_part_a_fields(resource: Resource): device_id = resource.attributes.get(ResourceAttributes.DEVICE_ID) device_model = resource.attributes.get(ResourceAttributes.DEVICE_MODEL_NAME) device_make = resource.attributes.get(ResourceAttributes.DEVICE_MANUFACTURER) + app_version = resource.attributes.get(ResourceAttributes.SERVICE_VERSION) if service_name: if service_namespace: tags[ContextTagKeys.AI_CLOUD_ROLE] = str(service_namespace) + \ @@ -199,6 +200,9 @@ def _populate_part_a_fields(resource: Resource): tags[ContextTagKeys.AI_DEVICE_MODEL] = device_model # type: ignore if device_make: tags[ContextTagKeys.AI_DEVICE_OEM_NAME] = device_make # type: ignore + if app_version: + tags[ContextTagKeys.AI_APPLICATION_VER] = app_version # type: ignore + return tags # pylint: disable=W0622 diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_utils.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_utils.py index 081d1ccebd36..f0b630453306 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_utils.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_utils.py @@ -51,7 +51,10 @@ def test_populate_part_a_fields(self): "service.instance.id": "testServiceInstanceId", "device.id": "testDeviceId", "device.model.name": "testDeviceModel", - "device.manufacturer": "testDeviceMake"}) + "device.manufacturer": "testDeviceMake", + "service.version": "testApplicationVer", + } + ) tags = _utils._populate_part_a_fields(resource) self.assertIsNotNone(tags) self.assertEqual(tags.get("ai.cloud.role"), "testServiceNamespace.testServiceName") @@ -60,6 +63,7 @@ def test_populate_part_a_fields(self): self.assertEqual(tags.get("ai.device.id"), "testDeviceId") self.assertEqual(tags.get("ai.device.model"), "testDeviceModel") self.assertEqual(tags.get("ai.device.oemName"), "testDeviceMake") + self.assertEqual(tags.get("ai.application.ver"), "testApplicationVer") def test_populate_part_a_fields_default(self): resource = Resource( From 8505b1ef95c0947ef62c0dd63b63edfcf29b8bdd Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Wed, 21 Feb 2024 11:11:04 -0800 Subject: [PATCH 2/2] lint --- sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md | 2 +- .../azure/monitor/opentelemetry/exporter/_utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md b/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md index 9b6c1d998825..71b019f04033 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md @@ -7,7 +7,7 @@ - Add device.* to part A fields ([#34229](https://github.com/Azure/azure-sdk-for-python/pull/34229)) - Add application.ver to part A fields - ([#34229](https://github.com/Azure/azure-sdk-for-python/pull/34229)) + ([#34401](https://github.com/Azure/azure-sdk-for-python/pull/34401)) ### Breaking Changes diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py index 01078adb19d9..a35d1c57751e 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py @@ -202,7 +202,7 @@ def _populate_part_a_fields(resource: Resource): tags[ContextTagKeys.AI_DEVICE_OEM_NAME] = device_make # type: ignore if app_version: tags[ContextTagKeys.AI_APPLICATION_VER] = app_version # type: ignore - + return tags # pylint: disable=W0622