diff --git a/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/MicrometerProcessor.java b/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/MicrometerProcessor.java index f3c45726769d0..e3e2e6e8076e2 100644 --- a/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/MicrometerProcessor.java +++ b/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/MicrometerProcessor.java @@ -75,6 +75,14 @@ public boolean getAsBoolean() { MicrometerConfig mConfig; + /** + * config objects are beans, but they are not unremoveable by default + */ + @BuildStep + UnremovableBeanBuildItem mpConfigAsBean() { + return UnremovableBeanBuildItem.beanTypes(MicrometerConfig.class); + } + @BuildStep(onlyIf = MicrometerEnabled.class) FeatureBuildItem feature() { return new FeatureBuildItem(Feature.MICROMETER); diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/RestClientMetricsListener.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/RestClientMetricsListener.java index 82457606eb9e5..a44a5cd1c7e96 100644 --- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/RestClientMetricsListener.java +++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/RestClientMetricsListener.java @@ -17,6 +17,7 @@ import io.micrometer.core.instrument.Tags; import io.micrometer.core.instrument.Timer; import io.quarkus.arc.Arc; +import io.quarkus.micrometer.runtime.config.MicrometerConfig; /** * This is initialized via ServiceFactory (static/non-CDI initialization) @@ -35,6 +36,10 @@ public class RestClientMetricsListener implements RestClientListener { @Override public void onNewClient(Class serviceInterface, RestClientBuilder builder) { + MicrometerConfig micrometerConfig = Arc.container().instance(MicrometerConfig.class).get(); + if (!micrometerConfig.enabled) { + return; + } if (prepClientMetrics()) { // This must run AFTER the OpenTelmetry client request filter builder.register(this.clientRequestFilter, Priorities.HEADER_DECORATOR + 1);