Skip to content

Commit

Permalink
Issue #3455: do not catch exceptions thrown by Observation supplier
Browse files Browse the repository at this point in the history
  • Loading branch information
nvervelle committed Jun 29, 2023
1 parent 942a2ce commit 3a611db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,9 @@ private static Observation defaultObservation(
MicrometerObservationListenerConfiguration configuration,
@Nullable Function<ObservationRegistry, Observation> observationSupplier) {
if (observationSupplier != null) {
try {
final Observation observation = observationSupplier.apply(configuration.registry);
if (observation != null) {
return observation;
}
} catch (final Exception e) {
LOGGER.error("Error creating observation with given supplier, use default supplier instead", e);
final Observation observation = observationSupplier.apply(configuration.registry);
if (observation != null) {
return observation;
}
}
return Observation.createNotStarted(configuration.sequenceName, configuration.registry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

import static io.micrometer.observation.tck.TestObservationRegistryAssert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

/**
* @author Simon Baslé
Expand Down Expand Up @@ -330,18 +331,8 @@ void tapFromMonoWithObservationSupplierThrowingException(boolean automatic) {

assertThat(registry).as("before subscription").doesNotHaveAnyObservation();

mono.block();

assertThat(registry)
.hasSingleObservationThat()
.hasNameEqualTo("testMono")
.hasContextualNameEqualTo("testMono")
.as("subscribeToTerminalObservation")
.hasBeenStarted()
.hasBeenStopped()
.hasLowCardinalityKeyValue("reactor.type", "Mono")
.hasLowCardinalityKeyValue("reactor.status", "completed")
.hasKeyValuesCount(2);
assertThatThrownBy(mono::block)
.isInstanceOf(IllegalStateException.class);
}

@ParameterizedTestWithName
Expand Down

0 comments on commit 3a611db

Please sign in to comment.