Skip to content

Commit dbad975

Browse files
committed
Unify the runtimeExceptionTemplate and errorTemplate into a throwableTemplate.
1 parent 23a0eda commit dbad975

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationTests.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public KeyValues getLowCardinalityKeyValues(KafkaRecordReceiverContext context)
239239

240240
@Test
241241
void observationRuntimeException(@Autowired ExceptionListener listener, @Autowired SimpleTracer tracer,
242-
@Autowired @Qualifier("runtimeExceptionTemplate") KafkaTemplate<Integer, String> runtimeExceptionTemplate,
242+
@Autowired @Qualifier("throwableTemplate") KafkaTemplate<Integer, String> runtimeExceptionTemplate,
243243
@Autowired KafkaListenerEndpointRegistry endpointRegistry)
244244
throws ExecutionException, InterruptedException, TimeoutException {
245245

@@ -250,7 +250,7 @@ void observationRuntimeException(@Autowired ExceptionListener listener, @Autowir
250250
Deque<SimpleSpan> spans = tracer.getSpans();
251251
assertThat(spans).hasSize(2);
252252
SimpleSpan span = spans.poll();
253-
assertThat(span.getTags().get("spring.kafka.template.name")).isEqualTo("runtimeExceptionTemplate");
253+
assertThat(span.getTags().get("spring.kafka.template.name")).isEqualTo("throwableTemplate");
254254
span = spans.poll();
255255
assertThat(span.getTags().get("spring.kafka.listener.id")).isEqualTo("obs4-0");
256256
assertThat(span.getError().getCause())
@@ -260,7 +260,7 @@ void observationRuntimeException(@Autowired ExceptionListener listener, @Autowir
260260

261261
@Test
262262
void observationErrorException(@Autowired ExceptionListener listener, @Autowired SimpleTracer tracer,
263-
@Autowired @Qualifier("errorTemplate") KafkaTemplate<Integer, String> errorTemplate,
263+
@Autowired @Qualifier("throwableTemplate") KafkaTemplate<Integer, String> errorTemplate,
264264
@Autowired KafkaListenerEndpointRegistry endpointRegistry)
265265
throws ExecutionException, InterruptedException, TimeoutException {
266266

@@ -271,7 +271,7 @@ void observationErrorException(@Autowired ExceptionListener listener, @Autowired
271271
Deque<SimpleSpan> spans = tracer.getSpans();
272272
assertThat(spans).hasSize(2);
273273
SimpleSpan span = spans.poll();
274-
assertThat(span.getTags().get("spring.kafka.template.name")).isEqualTo("errorTemplate");
274+
assertThat(span.getTags().get("spring.kafka.template.name")).isEqualTo("throwableTemplate");
275275
span = spans.poll();
276276
assertThat(span.getTags().get("spring.kafka.listener.id")).isEqualTo("obs5-0");
277277
assertThat(span.getError())
@@ -326,14 +326,7 @@ KafkaTemplate<Integer, String> customTemplate(ProducerFactory<Integer, String> p
326326
}
327327

328328
@Bean
329-
KafkaTemplate<Integer, String> runtimeExceptionTemplate(ProducerFactory<Integer, String> pf) {
330-
KafkaTemplate<Integer, String> template = new KafkaTemplate<>(pf);
331-
template.setObservationEnabled(true);
332-
return template;
333-
}
334-
335-
@Bean
336-
KafkaTemplate<Integer, String> errorTemplate(ProducerFactory<Integer, String> pf) {
329+
KafkaTemplate<Integer, String> throwableTemplate(ProducerFactory<Integer, String> pf) {
337330
KafkaTemplate<Integer, String> template = new KafkaTemplate<>(pf);
338331
template.setObservationEnabled(true);
339332
return template;

0 commit comments

Comments
 (0)