-
Notifications
You must be signed in to change notification settings - Fork 765
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
IHttpActivityFeature.Activity
and Activity.Current
don't return the same activity
#4466
Comments
Looks like an bug in the way Instrumentation.AspNetCore works. It has some logic to "ignore" the Activity created by Asp.Net Core itself, and create a new one. This is only meant to be triggered when non W3CTraceContext propagator is used, but it looks like it is triggered (incorrectly), in the case a traceparent with "00" traceflags is being sent. Looks like https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs#L138 should ignore traceflags from the comparison, as TraceFlags is expected to be changed, unlike traceid,spanid. |
@vishweshbankwar Could you take a look? |
@joegoldman2 We do not have an ETA on this. In the meantime, you could use |
OP account is deleted, but I can't reproduce this behavior in the given example with the current codebase. app.MapGet("/values", (HttpContext context) =>
{
var activity = context.Features.GetRequiredFeature<IHttpActivityFeature>().Activity;
activity.SetTag("test", "123");
Activity.Current?.SetTag("test2", "123");
var equal = Activity.Current.Id == activity.Id;
// equal is true
return Results.Ok();
}); |
@ngruson Did you send the |
Ah, the header. Will recheck tomorrow. |
Description
Considering the following example:
When the application receives a traceparent header with a trace-flags 00 (not sampled),
activity.Id
andActivity.Current.Id
don't have the same id but both activities have the same name:Microsoft.AspNetCore.Hosting.HttpRequestIn
.In addition, only tags added through
Activity.Current.SetTag
are taken into account.This seems to be a bug or an unexpected behaviour with the OpenTelemetry SDK as without the SDK both activities are the same and both tags are taken into account.
What is the expected behavior?
Both activities (the one from
IHttpActivityFeature.Activity
and the one fromActivity.Current
) should be the same.What is the actual behavior?
Both activities are not the same.
The text was updated successfully, but these errors were encountered: