DataDog / dd-trace-dotnet

.NET Client Library for Datadog APM
https://docs.datadoghq.com/tracing/
Apache License 2.0
413 stars 132 forks source link

Problem with Azure ServiceBus distributed trace #5326

Open brunohdossantos opened 3 months ago

brunohdossantos commented 3 months ago

I am unable to use the distributed trace to communicate between services using Azure Service Bus, the trace is only working when a service A communicates with a service B through a web api. I'm using the latest version of dd-trace-dotnet and the Azure ServiceBus SDK. From what I understand after this update https://github.com/DataDog/dd-trace-dotnet/pull/4575/files#diff-426121b5cc1e2b68a3fb5aef68641547dd3488c59332d4a79adf23be9460545d the propagation of the necessary contexts would be done automatically. Has anyone had success in this scenario?

zacharycmontoya commented 3 months ago

Hi @brunohdossantos, can you confirm the following information so I can help understand the setup you have:

  1. Are Service A (message sender) and Service B (message receiver) both using the Datadog .NET Tracer v2.38.0 or above, and do they both have environment variable DD_TRACE_OTEL_ENABLED=true? These are the pre-requisites for our Azure Service Bus instrumentation.
  2. Can you also confirm what version of the Azure.Messaging.ServiceBus SDK package you are using?
brunohdossantos commented 3 months ago

Hi @zacharycmontoya , yes I have the variable DD_TRACE_OTEL_ENABLED=true, i am using the Azure.Messaging.ServiceBus version - 7.17.14 and Datadog.Trace in version 2.49, the apm version is also 2.49.

When consuming the message, my service performs a _tracer.StartActive, could this be a problem?

brunohdossantos commented 3 months ago

Anyone with the same error? Or with the same scenario and working without problems ?

brunohdossantos commented 2 months ago

Has anyone experienced this problem, had a solution?

brunohdossantos commented 2 weeks ago

Do we have a solution for this problem?

rnarayana commented 2 weeks ago

I believe this also requires you to also set AZURE_EXPERIMENTAL_ENABLE_ACTIVITY_SOURCE to true, which injects traceparent into the message properties. This worked for me.

https://docs.datadoghq.com/tracing/trace_collection/compatibility/dotnet-core/#opentelemetry-based-integrations