diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs index 82f4a5bb271..3cfa789851f 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs @@ -118,11 +118,10 @@ public void OnStartActivity(Activity activity, object payload) if (textMapPropagator is not TraceContextPropagator) { var ctx = textMapPropagator.Extract(default, request, HttpRequestHeaderValuesGetter); - var activityContext = new ActivityContext(activity.TraceId, activity.ParentSpanId, activity.ActivityTraceFlags, activity.TraceStateString, true); if (ctx.ActivityContext.IsValid() - && !((ctx.ActivityContext.TraceId == activityContext.TraceId) - && (ctx.ActivityContext.SpanId == activityContext.SpanId) - && (ctx.ActivityContext.TraceState == activityContext.TraceState))) + && !((ctx.ActivityContext.TraceId == activity.TraceId) + && (ctx.ActivityContext.SpanId == activity.ParentSpanId) + && (ctx.ActivityContext.TraceState == activity.TraceStateString))) { // Create a new activity with its parent set from the extracted context. // This makes the new activity as a "sibling" of the activity created by