Skip to content

Commit 757f877

Browse files
authored
Add application.ver to Part A fields for exporter (#34401)
1 parent 7561277 commit 757f877

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
- Add device.* to part A fields
88
([#34229](https://github.com/Azure/azure-sdk-for-python/pull/34229))
9+
- Add application.ver to part A fields
10+
([#34401](https://github.com/Azure/azure-sdk-for-python/pull/34401))
911

1012
### Breaking Changes
1113

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ def _populate_part_a_fields(resource: Resource):
182182
device_id = resource.attributes.get(ResourceAttributes.DEVICE_ID)
183183
device_model = resource.attributes.get(ResourceAttributes.DEVICE_MODEL_NAME)
184184
device_make = resource.attributes.get(ResourceAttributes.DEVICE_MANUFACTURER)
185+
app_version = resource.attributes.get(ResourceAttributes.SERVICE_VERSION)
185186
if service_name:
186187
if service_namespace:
187188
tags[ContextTagKeys.AI_CLOUD_ROLE] = str(service_namespace) + \
@@ -199,6 +200,9 @@ def _populate_part_a_fields(resource: Resource):
199200
tags[ContextTagKeys.AI_DEVICE_MODEL] = device_model # type: ignore
200201
if device_make:
201202
tags[ContextTagKeys.AI_DEVICE_OEM_NAME] = device_make # type: ignore
203+
if app_version:
204+
tags[ContextTagKeys.AI_APPLICATION_VER] = app_version # type: ignore
205+
202206
return tags
203207

204208
# pylint: disable=W0622

sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ def test_populate_part_a_fields(self):
5151
"service.instance.id": "testServiceInstanceId",
5252
"device.id": "testDeviceId",
5353
"device.model.name": "testDeviceModel",
54-
"device.manufacturer": "testDeviceMake"})
54+
"device.manufacturer": "testDeviceMake",
55+
"service.version": "testApplicationVer",
56+
}
57+
)
5558
tags = _utils._populate_part_a_fields(resource)
5659
self.assertIsNotNone(tags)
5760
self.assertEqual(tags.get("ai.cloud.role"), "testServiceNamespace.testServiceName")
@@ -60,6 +63,7 @@ def test_populate_part_a_fields(self):
6063
self.assertEqual(tags.get("ai.device.id"), "testDeviceId")
6164
self.assertEqual(tags.get("ai.device.model"), "testDeviceModel")
6265
self.assertEqual(tags.get("ai.device.oemName"), "testDeviceMake")
66+
self.assertEqual(tags.get("ai.application.ver"), "testApplicationVer")
6367

6468
def test_populate_part_a_fields_default(self):
6569
resource = Resource(

0 commit comments

Comments
 (0)