From 2aa9fd9954e8796a28cc838df6d8de0ae483da55 Mon Sep 17 00:00:00 2001 From: Nils Gruson Date: Thu, 21 Dec 2023 21:30:05 +0100 Subject: [PATCH] Don't create ActivityContext struct for comparison --- .../Implementation/HttpInListener.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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