From 9c38849028df001f55c8bc45719c7d65ecf23f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sim=C3=A3o=20Ribeiro?= Date: Tue, 17 Oct 2023 16:07:38 +0100 Subject: [PATCH] test --- .../OpenTelemetryConsumerEventsHandler.cs | 6 ++++-- .../OpenTelemetryProducerEventsHandler.cs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/KafkaFlow.OpenTelemetry/OpenTelemetryConsumerEventsHandler.cs b/src/KafkaFlow.OpenTelemetry/OpenTelemetryConsumerEventsHandler.cs index 7785dd86e..43ce339cd 100644 --- a/src/KafkaFlow.OpenTelemetry/OpenTelemetryConsumerEventsHandler.cs +++ b/src/KafkaFlow.OpenTelemetry/OpenTelemetryConsumerEventsHandler.cs @@ -36,6 +36,8 @@ public static Task OnConsumeStarted(IMessageContext context) activity?.AddBaggage(item.Key, item.Value); } + Activity.Current = activity; + context?.Items.Add(ActivitySourceAccessor.ActivityString, activity); ActivitySourceAccessor.SetGenericTags(activity); @@ -57,7 +59,7 @@ public static Task OnConsumeCompleted(IMessageContext context) { if (context.Items.TryGetValue(ActivitySourceAccessor.ActivityString, out var value) && value is Activity activity) { - //activity?.Stop(); + activity?.Stop(); } return Task.CompletedTask; @@ -71,7 +73,7 @@ public static Task OnConsumeError(IMessageContext context, Exception ex) activity?.AddEvent(exceptionEvent); - //activity?.Stop(); + activity?.Stop(); } return Task.CompletedTask; diff --git a/src/KafkaFlow.OpenTelemetry/OpenTelemetryProducerEventsHandler.cs b/src/KafkaFlow.OpenTelemetry/OpenTelemetryProducerEventsHandler.cs index 14bc36733..ee82e22a6 100644 --- a/src/KafkaFlow.OpenTelemetry/OpenTelemetryProducerEventsHandler.cs +++ b/src/KafkaFlow.OpenTelemetry/OpenTelemetryProducerEventsHandler.cs @@ -67,7 +67,7 @@ public static Task OnProducerCompleted(IMessageContext context) { if (context.Items.TryGetValue(ActivitySourceAccessor.ActivityString, out var value) && value is Activity activity) { - //activity?.Stop(); + activity?.Stop(); } return Task.CompletedTask; @@ -81,7 +81,7 @@ public static Task OnProducerError(IMessageContext context, Exception ex) activity?.AddEvent(exceptionEvent); - //activity?.Stop(); + activity?.Stop(); } return Task.CompletedTask;