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 <christian.fredriksson.2@volvocars.com> **Auto-cherry-pick to `3.3.x` & `3.2.x`**
This commit is contained in:
committed by
GitHub
parent
cbbd1d45fe
commit
bdd1fd3556
@@ -805,8 +805,8 @@ public class KafkaTemplate<K, V> implements KafkaOperations<K, V>, ApplicationCo
|
||||
this.observationConvention, DefaultKafkaTemplateObservationConvention.INSTANCE,
|
||||
() -> new KafkaRecordSenderContext(producerRecord, this.beanName, this::clusterId),
|
||||
this.observationRegistry);
|
||||
observation.start();
|
||||
try {
|
||||
observation.start();
|
||||
try (Observation.Scope ignored = observation.openScope()) {
|
||||
return doSend(producerRecord, observation);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user