elastic / apm-agent-dotnet

https://www.elastic.co/guide/en/apm/agent/dotnet/current/index.html
Apache License 2.0
585 stars 208 forks source link

Fix span linking for Azure ServiceBus #2474

Closed stevejgordon closed 2 weeks ago

stevejgordon commented 3 weeks ago

Align span ID with activity's span ID in ServiceBus listener

The code changes in the AzureMessagingServiceBusDiagnosticListener.cs file within the Elastic.Apm.Azure.ServiceBus namespace involve modifications to how spans are started for message actions. Specifically, the StartSpanInternal method now includes an explicit id parameter set to activity.SpanId.ToString(). This change ensures that the span ID matches the activity's span ID, which is crucial for correctly linking the consuming span to the producer. This adjustment is necessary because the Azure SDK automatically attaches the diagnostic-id and traceparent to the message, and proper span linking on the receiver end depends on this alignment.