From 59e5a807aa2b91a401a9eb7240ad079438f12652 Mon Sep 17 00:00:00 2001 From: Soby Chacko Date: Tue, 23 Apr 2024 13:22:00 -0400 Subject: [PATCH] GH-3210: KafkaTemplate currentSpan tagging issue Fixes: #3210 * When adding a tag to the current span during the sending of a kafka message using KafkaTemplate, the tag gets added to another span because KafkaTemplate doesn't open the scope for the started observation. Fixing this issue by wrapping the doSend method call in a proper observation scope. **Auto-cherry-pick to `3.0.x`** # Conflicts: # spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationTests.java --- .../java/org/springframework/kafka/core/KafkaTemplate.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-kafka/src/main/java/org/springframework/kafka/core/KafkaTemplate.java b/spring-kafka/src/main/java/org/springframework/kafka/core/KafkaTemplate.java index 630c220b79..96b2460fac 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/core/KafkaTemplate.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/core/KafkaTemplate.java @@ -770,7 +770,9 @@ private CompletableFuture> observeSend(final ProducerRecord