diff --git a/micrometer-observation/src/main/java/io/micrometer/observation/NoopObservationRegistry.java b/micrometer-observation/src/main/java/io/micrometer/observation/NoopObservationRegistry.java index 4dd252d138..b94d4ada00 100644 --- a/micrometer-observation/src/main/java/io/micrometer/observation/NoopObservationRegistry.java +++ b/micrometer-observation/src/main/java/io/micrometer/observation/NoopObservationRegistry.java @@ -26,16 +26,11 @@ */ final class NoopObservationRegistry implements ObservationRegistry { - /** - * Instance of {@link NoopObservationRegistry}. - */ - static final NoopObservationRegistry INSTANCE = new NoopObservationRegistry(); - static final ObservationRegistry FOR_SCOPES = ObservationRegistry.create(); private final ObservationConfig observationConfig = NoopObservationConfig.INSTANCE; - private NoopObservationRegistry() { + NoopObservationRegistry() { } @Override diff --git a/micrometer-observation/src/main/java/io/micrometer/observation/ObservationRegistry.java b/micrometer-observation/src/main/java/io/micrometer/observation/ObservationRegistry.java index be95a99b8a..642fb90d62 100644 --- a/micrometer-observation/src/main/java/io/micrometer/observation/ObservationRegistry.java +++ b/micrometer-observation/src/main/java/io/micrometer/observation/ObservationRegistry.java @@ -45,7 +45,7 @@ static ObservationRegistry create() { /** * No-op implementation of {@link ObservationRegistry}. */ - ObservationRegistry NOOP = NoopObservationRegistry.INSTANCE; + ObservationRegistry NOOP = new NoopObservationRegistry(); /** * When previously set will allow to retrieve the {@link Observation} at any point in diff --git a/micrometer-observation/src/test/java/io/micrometer/observation/ObservationTests.java b/micrometer-observation/src/test/java/io/micrometer/observation/ObservationTests.java index 230978d4c0..bdba69bc10 100644 --- a/micrometer-observation/src/test/java/io/micrometer/observation/ObservationTests.java +++ b/micrometer-observation/src/test/java/io/micrometer/observation/ObservationTests.java @@ -397,12 +397,12 @@ void observeWithFunction() { } }; AtomicReference passedContextHolder = new AtomicReference<>(); - result = Observation.createNotStarted("service", supplier, NoopObservationRegistry.INSTANCE) + result = Observation.createNotStarted("service", supplier, ObservationRegistry.NOOP) .observeWithContext((ctx) -> { passedContextHolder.set(ctx); return "World"; }); - assertThat(passedContextHolder).as("passed a noop context").hasValue(NoopObservation.NOOP.getContext()); + assertThat(passedContextHolder).as("passed a noop context").hasValue(Observation.NOOP.getContext()); assertThat(contextCreated).isFalse(); assertThat(result).isEqualTo("World"); }