Skip to content

Commit

Permalink
Remove ObservationTests.observationErrorException
Browse files Browse the repository at this point in the history
The Micrometer Observation of version `1.10`
does not support catching `Error` yet
  • Loading branch information
artembilan committed Mar 14, 2024
1 parent a2b0abc commit 3188c06
Showing 1 changed file with 1 addition and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,12 @@
*/
@SpringJUnitConfig
@EmbeddedKafka(topics = { "observation.testT1", "observation.testT2", "observation.testT3",
ObservationTests.OBSERVATION_RUNTIME_EXCEPTION, ObservationTests.OBSERVATION_ERROR})
ObservationTests.OBSERVATION_RUNTIME_EXCEPTION})
@DirtiesContext
public class ObservationTests {

public final static String OBSERVATION_RUNTIME_EXCEPTION = "observation.runtime-exception";

public final static String OBSERVATION_ERROR = "observation.error";

@Test
void endToEnd(@Autowired Listener listener, @Autowired KafkaTemplate<Integer, String> template,
@Autowired SimpleTracer tracer, @Autowired KafkaListenerEndpointRegistry rler,
Expand Down Expand Up @@ -256,27 +254,6 @@ void observationRuntimeException(@Autowired ExceptionListener listener, @Autowir
.hasMessage("obs4 run time exception");
}

@Test
void observationErrorException(@Autowired ExceptionListener listener, @Autowired SimpleTracer tracer,
@Autowired @Qualifier("throwableTemplate") KafkaTemplate<Integer, String> errorTemplate,
@Autowired KafkaListenerEndpointRegistry endpointRegistry)
throws ExecutionException, InterruptedException, TimeoutException {

errorTemplate.send(OBSERVATION_ERROR, "testError").get(10, TimeUnit.SECONDS);
assertThat(listener.latch5.await(10, TimeUnit.SECONDS)).isTrue();
endpointRegistry.getListenerContainer("obs5").stop();

Deque<SimpleSpan> spans = tracer.getSpans();
assertThat(spans).hasSize(2);
SimpleSpan span = spans.poll();
assertThat(span.getTags().get("spring.kafka.template.name")).isEqualTo("throwableTemplate");
span = spans.poll();
assertThat(span.getTags().get("spring.kafka.listener.id")).isEqualTo("obs5-0");
assertThat(span.getError())
.isInstanceOf(Error.class)
.hasMessage("obs5 error");
}

@Configuration
@EnableKafka
public static class Config {
Expand Down Expand Up @@ -457,12 +434,6 @@ void listenRuntimeException(ConsumerRecord<Integer, String> in) {
throw new IllegalStateException("obs4 run time exception");
}

@KafkaListener(id = "obs5", topics = OBSERVATION_ERROR)
void listenError(ConsumerRecord<Integer, String> in) {
this.latch5.countDown();
throw new Error("obs5 error");
}

}

}

0 comments on commit 3188c06

Please sign in to comment.