Add failing test for StartRootSpan #2878
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relates to #2803
Just adding a test for now for discussion and to determine whether there's something we can do at the moment.
It appears the
StartActivity
method starts a new span parented fromActivity.Current
even when you pass in a newParentContext
. I imagine this might be by design sinceActivity.Current
is tracked viaAsyncLocal
and maybeStartActivity
doesn't want to clobber that state.opentelemetry-dotnet/src/OpenTelemetry.Api/Trace/Tracer.cs
Lines 79 to 82 in 6b7f2dd
opentelemetry-dotnet/src/OpenTelemetry.Api/Trace/Tracer.cs
Lines 167 to 195 in 6b7f2dd
In a scenario where a thread hop has occurred - as in this test - maybe it would be more intuitive to wipe out
Activity.Current
... though, not sure there's a way for us to detect we're on a new thread.Confirmed that
StartActivity
usesActivity.Current
when the parent'sActivityContext == default
https://github.com/dotnet/runtime/blob/3ae87395f638a533f37b8e3385f6d3f199a72f4f/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/ActivitySource.cs#L252-L253