From ba507428777dea428519b1d2433680e0df8e6f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sim=C3=A3o=20Ribeiro?= Date: Fri, 13 Oct 2023 16:49:30 +0100 Subject: [PATCH] code reviews --- .../OpenTelemetryProducerEventsHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KafkaFlow.OpenTelemetry/OpenTelemetryProducerEventsHandler.cs b/src/KafkaFlow.OpenTelemetry/OpenTelemetryProducerEventsHandler.cs index 712c85d90..62f703325 100644 --- a/src/KafkaFlow.OpenTelemetry/OpenTelemetryProducerEventsHandler.cs +++ b/src/KafkaFlow.OpenTelemetry/OpenTelemetryProducerEventsHandler.cs @@ -26,8 +26,6 @@ public static Task OnProducerStarted(IMessageContext context) // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/messaging.md var activity = ActivitySourceAccessor.ActivitySource.StartActivity(activityName, ActivityKind.Producer); - context?.Items.Add(ActivitySourceAccessor.ActivityString, activity); - // Depending on Sampling (and whether a listener is registered or not), the // activity above may not be created. // If it is created, then propagate its context. @@ -36,6 +34,8 @@ public static Task OnProducerStarted(IMessageContext context) if (activity != null) { + context?.Items.Add(ActivitySourceAccessor.ActivityString, activity); + contextToInject = activity.Context; } else if (Activity.Current != null)