-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support W3C Baggage propagation without Activity #103174
Comments
Tagging subscribers to this area: @dotnet/area-system-diagnostics-activity |
Where is that implication coming from? Isn't the entire |
In order to add/get/propagate a baggage, someone needs to create an There is nothing otel-specific in this issue description, so I'm not sure I understand your concern @julealgon. |
@lmolkova could you elaborate a bit on why this is needed and to which use cases it would apply? |
service-a: NewBaggage.Current.Add("foo", "bar");
DistributeContextPropagator.Current.InjectBaggage(NewBaggage.Current, httpRequest, ...); service-b var baggage = DistributeContextPropagator.Current.ExtractBaggage(NewBaggage.Current, httpRequest, ...);
NewBaggage.Current = new NewBaggage(baggage)
var foo = NewBaggage.Current.Get("foo");
...
// do anything with it. Someone can use baggage to augment their telemetry (e.g. metrics or logs), to route requests in their application, or do absolutely anything with it. |
Thanks for the example @lmolkova , that helps. All that |
Not sure what is the alternative here? |
To be fair I don't know either, was just a bit disappointed by the fact it's just a random Wouldn't it make sense to somehow couple this with the My sentiment when seeing all this static provider-based stuff is that I'm working on a lower-level language. |
I am not sure if I understood the question well. What is "provider" here? Sure, OpenTelemetry has notion of various providers, but |
What I meant by "provider" is the pattern that allows you to assign and retrieve an implementation in a I was basically referring to this old system:
When DI became "a thing", this "style" was largely abandoned, but there are still a few usages of the pattern in modern code. I'd personally rather see something around the hosting abstractions than this. |
Thanks for clarifying the provider part!
|
The baggage and propagator need to be available to HttpClient and libraries that work without dependency injection. |
It honestly isn't clear what type in .NET is supposed to map to OTel It almost feels like Like Activity is trying to fill this role (in addition to being the representation of a If we actually look for a class that fits, the closest we get is The OTel specification requires that Baggage be an immutable collection stored within the context, with an add method that returns a new collection (users would then use appropriate APIs to add it to a context). Obviously helper APIs to create a new context with an additional baggage item is fine too, and/or one that updates the implicit context. It also needs a remove API (.NET currently supports remove via a SetBaggage API, where setting a value of null is same as removing). However, .NET is non-conforming here. It has no reified baggage type (which is not strictly a violation, APIs directly on the context are also legal). It stores baggage in the activity rather than the context, and the current set baggage method updates the current Activity in place. Additionally trying to use SetBaggage with null to remove baggage only works with respect to baggage on the current activity, not for baggage inherited from a parent activity. .NET also currently fails to provide the required API for removing all baggage from a context (or to be more accurate: creating a new context with all baggage info removed, possibly setting that as the implicit context), which the OTEL spec considers critical to avoid sending potentially sensitive information to an untrusted API. Besides the obvious issue of being unable to remove baggage from parent activities, and being unable to clear all baggage, the current .NET design means that it is not possible to capture the Context (be it ExecutionContext or Activity), prior to adding baggage, adding the baggage for some operations, and then restoring to a context without that baggage. |
I want to add that the Otel Baggage is no where close to an AsyncLocal - see open-telemetry/opentelemetry-dotnet#3257 |
Related to #45496
W3C Baggage defines a propagation format for arbitrary application-specific properties.
Despite being driven by the observability community, it's not related to W3C Trace-Context and could work without distributed tracing.
In .NET however, baggage API is part of the
System.Diagnostics.Activity
which allows to get/set baggage. It implies that users have to have distributed tracing enabled in order to propagate baggage.To support W3C Baggage fully, .NET would need to define an API similar to OTel Baggage:
NewBaggage.Current
would be backed up byAsyncLocal
NewBaggage
would allow to add/get/remove/enumerate baggageIt could be done in a backward compatible way such that
Activity.Baggage
would work overNewBaggage
, but it would be great to consider an alternative approach of sunsettingActivity.Baggage
or at least methods allowing to add/modify it.The text was updated successfully, but these errors were encountered: