File tree 3 files changed +19
-1
lines changed
sdk/monitor/azure-monitor-opentelemetry-exporter
azure/monitor/opentelemetry/exporter
3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 4
4
5
5
### Features Added
6
6
7
+ - Add device.* to part A fields
8
+ ([ #34229 ] ( https://github.com/Azure/azure-sdk-for-python/pull/34229 ) )
9
+
7
10
### Breaking Changes
8
11
9
12
### Bugs Fixed
Original file line number Diff line number Diff line change @@ -161,6 +161,9 @@ def _populate_part_a_fields(resource: Resource):
161
161
service_name = resource .attributes .get (ResourceAttributes .SERVICE_NAME )
162
162
service_namespace = resource .attributes .get (ResourceAttributes .SERVICE_NAMESPACE )
163
163
service_instance_id = resource .attributes .get (ResourceAttributes .SERVICE_INSTANCE_ID )
164
+ device_id = resource .attributes .get (ResourceAttributes .DEVICE_ID )
165
+ device_model = resource .attributes .get (ResourceAttributes .DEVICE_MODEL_NAME )
166
+ device_make = resource .attributes .get (ResourceAttributes .DEVICE_MANUFACTURER )
164
167
if service_name :
165
168
if service_namespace :
166
169
tags [ContextTagKeys .AI_CLOUD_ROLE ] = str (service_namespace ) + \
@@ -172,6 +175,12 @@ def _populate_part_a_fields(resource: Resource):
172
175
else :
173
176
tags [ContextTagKeys .AI_CLOUD_ROLE_INSTANCE ] = platform .node () # hostname default
174
177
tags [ContextTagKeys .AI_INTERNAL_NODE_NAME ] = tags [ContextTagKeys .AI_CLOUD_ROLE_INSTANCE ]
178
+ if device_id :
179
+ tags [ContextTagKeys .AI_DEVICE_ID ] = device_id # type: ignore
180
+ if device_model :
181
+ tags [ContextTagKeys .AI_DEVICE_MODEL ] = device_model # type: ignore
182
+ if device_make :
183
+ tags [ContextTagKeys .AI_DEVICE_OEM_NAME ] = device_make # type: ignore
175
184
return tags
176
185
177
186
# pylint: disable=W0622
Original file line number Diff line number Diff line change @@ -48,12 +48,18 @@ def test_populate_part_a_fields(self):
48
48
resource = Resource (
49
49
{"service.name" : "testServiceName" ,
50
50
"service.namespace" : "testServiceNamespace" ,
51
- "service.instance.id" : "testServiceInstanceId" })
51
+ "service.instance.id" : "testServiceInstanceId" ,
52
+ "device.id" : "testDeviceId" ,
53
+ "device.model.name" : "testDeviceModel" ,
54
+ "device.manufacturer" : "testDeviceMake" })
52
55
tags = _utils ._populate_part_a_fields (resource )
53
56
self .assertIsNotNone (tags )
54
57
self .assertEqual (tags .get ("ai.cloud.role" ), "testServiceNamespace.testServiceName" )
55
58
self .assertEqual (tags .get ("ai.cloud.roleInstance" ), "testServiceInstanceId" )
56
59
self .assertEqual (tags .get ("ai.internal.nodeName" ), "testServiceInstanceId" )
60
+ self .assertEqual (tags .get ("ai.device.id" ), "testDeviceId" )
61
+ self .assertEqual (tags .get ("ai.device.model" ), "testDeviceModel" )
62
+ self .assertEqual (tags .get ("ai.device.oemName" ), "testDeviceMake" )
57
63
58
64
def test_populate_part_a_fields_default (self ):
59
65
resource = Resource (
You can’t perform that action at this time.
0 commit comments