Skip to content

Commit ec63436

Browse files
committed
Fix KafkaTemplate hiding exceptions when starting observation
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: cfredri4 <[email protected]>
1 parent cbbd1d4 commit ec63436

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
@@ -805,8 +805,8 @@ private CompletableFuture<SendResult<K, V>> observeSend(final ProducerRecord<K,
805805
this.observationConvention, DefaultKafkaTemplateObservationConvention.INSTANCE,
806806
() -> new KafkaRecordSenderContext(producerRecord, this.beanName, this::clusterId),
807807
this.observationRegistry);
808+
observation.start();
808809
try {
809-
observation.start();
810810
try (Observation.Scope ignored = observation.openScope()) {
811811
return doSend(producerRecord, observation);
812812
}

0 commit comments

Comments
 (0)