Skip to content

Commit 5726123

Browse files
cfredri4spring-builds
authored andcommitted
GH-3779: Fix KafkaTemplate from hiding error when starting observation
Fixes: #3779 This fixes that exceptions thrown from `observation.start()` are hidden by `KafkaTemplate` throwing a new exception due to registering observation error without successfully starting the observation. Signed-off-by: Christian Fredriksson <[email protected]> (cherry picked from commit bdd1fd3)
1 parent 855d294 commit 5726123

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

spring-kafka/src/main/java/org/springframework/kafka/core/KafkaTemplate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,8 @@ private CompletableFuture<SendResult<K, V>> observeSend(final ProducerRecord<K,
799799
this.observationConvention, DefaultKafkaTemplateObservationConvention.INSTANCE,
800800
() -> new KafkaRecordSenderContext(producerRecord, this.beanName, this::clusterId),
801801
this.observationRegistry);
802+
observation.start();
802803
try {
803-
observation.start();
804804
try (Observation.Scope ignored = observation.openScope()) {
805805
return doSend(producerRecord, observation);
806806
}

0 commit comments

Comments
 (0)