Skip to content

Commit 0dc14f1

Browse files
authored
[Monitor Exporter] Update Azure SDK messaging span util (Azure#40059)
The utility method that gets the target source for Azure SDK messaging spans will now also check for `server.address`. A newer version of the core OTel plugin will automatically convert `net.peer.name` to `server.address`. This ensures that this case can be handled. Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
1 parent 572a8e3 commit 0dc14f1

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
- Support `syntheticSource` from `user_agent.synthetic.type` semantic convention
88
([#40004](https://github.com/Azure/azure-sdk-for-python/pull/40004))
9+
- Support `server.address` attributes when converting Azure SDK messaging spans to envelopes
10+
([#40059](https://github.com/Azure/azure-sdk-for-python/pull/40059))
911

1012
### Breaking Changes
1113

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ def _get_azure_sdk_target_source(attributes: Attributes) -> Optional[str]:
6868
# Currently logic only works for ServiceBus and EventHub
6969
if attributes:
7070
# New semconv attributes: https://github.com/Azure/azure-sdk-for-python/pull/29203
71-
# TODO: Keep track of when azure-sdk supports stable semconv for these fields
72-
peer_address = attributes.get("net.peer.name") or attributes.get("peer.address")
71+
peer_address = (
72+
attributes.get("server.address") or attributes.get("net.peer.name") or attributes.get("peer.address")
73+
)
7374
destination = attributes.get("messaging.destination.name") or attributes.get("message_bus.destination")
7475
if peer_address and destination:
7576
return str(peer_address) + "/" + str(destination)

sdk/monitor/azure-monitor-opentelemetry-exporter/tests/trace/test_trace.py

+8
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,14 @@ def test_span_envelope_request_azure(self):
10021002
envelope = exporter._span_to_envelope(span)
10031003
self.assertEqual(envelope.data.base_data.source, "Test_name//testdest")
10041004

1005+
span._attributes = {
1006+
"az.namespace": "Microsoft.EventHub",
1007+
"server.address": "Test_name",
1008+
"messaging.destination.name": "/testdest",
1009+
}
1010+
envelope = exporter._span_to_envelope(span)
1011+
self.assertEqual(envelope.data.base_data.source, "Test_name//testdest")
1012+
10051013
def test_span_envelope_server_http(self):
10061014
exporter = self._exporter
10071015
start_time = 1575494316027613500

0 commit comments

Comments
 (0)