Closed Barsonax closed 3 weeks ago
@Barsonax - Do you have a repro?
Iam able to reproduce it in our codebase with the steps above if that's what you mean.
The header Correlation-Context
is not added by the OTel SDK but by the runtime in HttpHandlerDiagnosticListener
.
https://github.com/dotnet/runtime/issues/45496 is tracking the replacement of this header by baggage
. But for the moment the baggage
spec is still in draft, so the issue is on standby.
Thanks for your answer! So if I understand this correctly its not just azure functions but the whole .net ecosystem that uses the old header then?
EDIT: I do see something was changed in aspnet: https://github.com/dotnet/aspnetcore/pull/28328/files
By default, ASP.NET Core uses LegacyPropagator
which supports the extraction from baggage
header with a fallback to Correlation-Context
.
Ok that atleast clarifies alot. I wrote my own azure functions middleware to workaround the context not propagating. I think I will stick with that for now till this gets fixed in dotnet. Again thanks for the answers so I don't have to keep digging.
Hi @Barsonax , can you share more details about your Functions App? Is it InProc or Isolated?
Its a .net 8.0 isolated function app but I think @joegoldman2 already clarified that its a issue in dotnet itself. Only aspnet has a propagator that supports both headers.
@Barsonax - Just adding some clarification here:
HttpClientInstrumentation does not propagate the baggage that is set via Activity.Current?.SetBaggage("foobar2", "fus43gf3g3")
You would need to Use Baggage API for that. https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/src/OpenTelemetry.Api#baggage-api
This is actually a runtime bug, not an OpenTelemetry bug. If you use the Baggage API from OpenTelemetry, this should work fine. We could do better at documenting it in the OpenTelemetry docs though.
I'm suggesting that the runtime team look into this, and we close the issue in our repo.
@Barsonax - Just adding some clarification here:
HttpClientInstrumentation does not propagate the baggage that is set via
Activity.Current?.SetBaggage("foobar2", "fus43gf3g3")
You would need to Use Baggage API for that. https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/src/OpenTelemetry.Api#baggage-api
That's super confusing in the api. Will try this out and report back.
@Barsonax - Just adding some clarification here: HttpClientInstrumentation does not propagate the baggage that is set via
Activity.Current?.SetBaggage("foobar2", "fus43gf3g3")
You would need to Use Baggage API for that. https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/src/OpenTelemetry.Api#baggage-apiThat's super confusing in the api. Will try this out and report back.
"The recommended way to add Baggage is to use the Baggage.SetBaggage() API. OpenTelemetry users should not use the Activity.AddBaggage method."
There is this wording in the docs to warn about this already. It is not an ideal situation, and something that needs to be fixed. See https://github.com/open-telemetry/opentelemetry-dotnet/issues/5667 for some more details on this same topic.
The header
Correlation-Context
is not added by the OTel SDK but by the runtime inHttpHandlerDiagnosticListener
.dotnet/runtime#45496 is tracking the replacement of this header by
baggage
. But for the moment thebaggage
spec is still in draft, so the issue is on standby.
The baggage
propagation spec from W3C just moved to candidate recommendation : https://www.w3.org/TR/baggage/
Closing as this is working as expected. https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/1848#issuecomment-2143545720
So tested this to be sure and for anyone that stumbles on this:
Component
OpenTelemetry.Instrumentation.Http
Package Version
Runtime Version
net8.0, azure functions
Description
When instrumenting httpclient in azure functions and adding baggage the request send by httpclient does not contain the baggage header. Instead the older Correlation-Context is being used.
Steps to Reproduce
Activity.Current?.SetBaggage("foobar2", "fus43gf3g3");
Expected Result
baggage header is used instead of the correlation-context header
Actual Result
correlation-context header is used
Additional Context
No response