Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.17k stars 4.53k forks source link

[QUERY]: Is OpenTelemetry Baggage supported #44348

Closed MarcusKohnert closed 1 month ago

MarcusKohnert commented 1 month ago

Library name and version

Azure.Messaging.ServiceBus 7.17.5

Query/Question

@lmolkova wrote here that OpenTelemetry Baggage will be gradually adopted once it is approved.

I couldn't find any information if that adoption took place already. Here it sounds like it should work.

I couldn't get Baggage propagation over process boundaries working in my local development setup.

This is my scenario:

Process A, populates Baggage items via Activity.Current?.SetBaggage("", "") Process A, sends message to Azure Service Bus Process B, receives message from Azure Service Bus

Expected result:

Process B, Activity.Current has Baggage items

Actual result:

Process B, Activity.Current has no baggage

Is Baggage propagation already supposed to work? If yes, do I need to turn on specific things (Flags or similar)? Is maybe the transport mechanism to ServiceBus relevant?

Thanks for any hints or pointers?

Environment

dotnet --info .NET SDK: Version: 8.0.204 Commit: c338c7548c Workload version: 8.0.200-manifests.7d36c14f Runtime: OS Name: Windows OS Version: 10.0.19045 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.204\

github-actions[bot] commented 1 month ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.

jsquire commented 1 month ago

@lmolkova : Would you mind offering your insight?

lmolkova commented 1 month ago

Thanks @MarcusKohnert !

The short answer is no, unfortunately Baggage is not supported - https://github.com/Azure/azure-sdk/issues/6959 The long answer - we don't have a good way to support it in OTel-compatible way - https://github.com/open-telemetry/opentelemetry-dotnet/issues/5667:

TL;DR: OTel does not recommend using Activity.Baggage and does not support propagating it. It has a separate baggage implementation outside of .NET BCL. The propagation used by .NET is DistributedContextPropagator - its default implementation uses a different header name (Correlation-Context) than OTel (https://w3c.github.io/baggage/).

If we did use DistributedContextPropagator in .NET libraries, our .NET messaging would become incompatible with our instrumentation in other languages in the default case.

So the only viable path forward I see is to fix the problem on the OTel side before we can support baggage properly.

github-actions[bot] commented 1 month ago

Hi @MarcusKohnert. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.

MarcusKohnert commented 1 month ago

@lmolkova Thank you very much for the explanation.