Closed Aaronontheweb closed 2 years ago
Could you try the following lines well before the 1st activity is even triggered? In .NET Core 3.1, I think Activity uses the legacy id formats to be back-compact, so want to rule that out first.
Activity.DefaultIdFormat = ActivityIdFormat.W3C;
Activity.ForceDefaultIdFormat = true;
If this doesn't help, yes a simple unit test showing the issue would really help.
I'll give that a try real fast.
Can confirm that this resolved the issue.
Although, not sure if that's something that should still be patched or not
SDK already does this inside a static ctor. https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry/Sdk.cs#L38-L39
But there are cases where activity is created even before the OTel SDK is initialized, requiring manually forcing this (as you did to recover from this issue.)
Only an issue for .NET Core 3.1, as .NET 5 onwards, W3CTraceContext format is the default.
Bug Report
Using
OpenTelemetry.Api
1.2.0-rc1 and the following packages:Runtime version: ASP.NET Core 3.1 / netcore3.1
Tracer configuration looks like this:
Symptom
When executing an integration test against our custom OTel instrumentation for Akka.NET, we have the following reproduction specification:
And we use the following assertion method to assert that all traces gathered underneath this scenario and others like it are all correctly correlated together:
This assertion always fails for the first test in this assembly with the following exception:
And then this appears in the logs:
It appears as though the
Microsoft.AspNetCore.Hosting.HttpRequestIn
trace, the first in this test, is set todefault(ActivityContext)
. If I attempt to do a manual activity using theOpenTelemetry.Api.Trace.Tracer
methods, that will also show up withdefault(ActivityContext)
under this method - so it's not the ASP.NET Core instrumentation that is at fault here.I've been able to work around this issue by generating a fake span at the start of each test and then purging it from my in-memory collection:
What is the expected behavior?
All completed spans should have a valid
ActivityContext
that includes the correctTraceId
andSpanId
s.What is the actual behavior?
The first span is
default(ActivityContext)
Reproduce
I believe the above unit test should be reproducible, but I can contribute a clean version of that to the project if it'd be helpful.