microsoft / ApplicationInsights-dotnet

ApplicationInsights-dotnet
MIT License
565 stars 287 forks source link

Difference in behaviour between Microsoft.Azure.ServiceBus and Azure.Messaging.ServiceBus for adding Activity Tags to telemetry #2861

Open CallumRBreen opened 7 months ago

CallumRBreen commented 7 months ago

Hi,

Previously, when using the library, Microsoft.Azure.ServiceBus, if I added a custom property to the activity like so:

Activity.Current.Tags.Add("customProperty", "123")

When viewing the Request telemetry in Application Insights, it would show up under "Custom Properties". Which isn't the case for the newer library, Azure.Messaging.ServiceBus.

I've looked into why this might be, and found that the libraries use different DiagnosticEventHandlers: Microsoft.Azure.ServiceBus uses ServiceBusDiagnosticsEventHandler which populates every tag on the Activity in the method OnEvent Azure.Messaging.ServiceBus uses AzureSdkDiagnosticsEventHandler, overrides PopulateTags, but doesn't populate the telemetry object.

Was this an intended change, and is there an alternative that I can use?