Skip to content

Commit 5a317dd

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 f4dbf9a commit 5a317dd

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
@@ -786,8 +786,8 @@ private CompletableFuture<SendResult<K, V>> observeSend(final ProducerRecord<K,
786786
this.observationConvention, DefaultKafkaTemplateObservationConvention.INSTANCE,
787787
() -> new KafkaRecordSenderContext(producerRecord, this.beanName, this::clusterId),
788788
this.observationRegistry);
789+
observation.start();
789790
try {
790-
observation.start();
791791
try (Observation.Scope ignored = observation.openScope()) {
792792
return doSend(producerRecord, observation);
793793
}

0 commit comments

Comments
 (0)