Repository: quarkusio/quarkus
Issue: Deactivating Micrometer default binders

### Describe the bug

It's not possible to deactivate the default Micrometer binders with a single property.

### Expected behavior

Should be able to set:

```
quarkus.micrometer.binder-enabled-default=false
```

### Actual behavior

Needed to set:

```
quarkus.micrometer.binder-enabled-default=false
quarkus.micrometer.binder.jvm=false
quarkus.micrometer.binder.system=false
```

### How to Reproduce?

_No response_

### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

_No response_

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

_No response_

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

_No response_

### Additional information

_No response_

Changed files:
extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/MicrometerConfig.java
extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/MicrometerRecorder.java
extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/GlobalDefaultDisabledTest.java
extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/export/NoDefaultPrometheusTest.java

diff --git a/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/GlobalDefaultDisabledTest.java b/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/GlobalDefaultDisabledTest.java
index 1f311fabe1f..70464d7ad25 100644
--- a/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/GlobalDefaultDisabledTest.java
+++ b/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/GlobalDefaultDisabledTest.java
@@ -10,8 +10,8 @@
 
 import io.micrometer.core.instrument.MeterRegistry;
 import io.micrometer.core.instrument.composite.CompositeMeterRegistry;
+import io.quarkus.micrometer.test.Util;
 import io.quarkus.test.QuarkusUnitTest;
-import io.restassured.RestAssured;
 
 /**
  * Should not have any registered MeterRegistry objects when micrometer is disabled
@@ -23,7 +23,8 @@ public class GlobalDefaultDisabledTest {
             .withConfigurationResource("test-logging.properties")
             .overrideConfigKey("quarkus.micrometer.registry-enabled-default", "false")
             .overrideConfigKey("quarkus.micrometer.binder-enabled-default", "false")
-            .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
+            .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
+                    .addClasses(Util.class));
 
     @Inject
     MeterRegistry registry;
@@ -32,13 +33,14 @@ public class GlobalDefaultDisabledTest {
     public void testMeterRegistryPresent() {
         // Composite Meter Registry
         Assertions.assertNotNull(registry, "A registry should be configured");
+
         Assertions.assertTrue(registry instanceof CompositeMeterRegistry,
                 "Injected registry should be a CompositeMeterRegistry, was " + registry.getClass().getName());
-    }
 
-    @Test
-    public void testNoPrometheusEndpoint() {
-        // Micrometer is enabled, prometheus is not.
-        RestAssured.when().get("/prometheus").then().statusCode(404);
+        Assertions.assertTrue(((CompositeMeterRegistry) registry).getRegistries().isEmpty(),
+                "No child registries should be present: " + ((CompositeMeterRegistry) registry).getRegistries());
+
+        Assertions.assertNull(registry.find("jvm.info").counter(),
+                "JVM Info counter should not be present, found: " + Util.listMeters(registry, "jvm.info"));
     }
 }
diff --git a/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/export/NoDefaultPrometheusTest.java b/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/export/NoDefaultPrometheusTest.java
index 169a5cf2760..760ce9abb34 100644
--- a/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/export/NoDefaultPrometheusTest.java
+++ b/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/export/NoDefaultPrometheusTest.java
@@ -22,6 +22,7 @@ public class NoDefaultPrometheusTest {
             .setFlatClassPath(true)
             .withConfigurationResource("test-logging.properties")
             .overrideConfigKey("quarkus.micrometer.binder-enabled-default", "false")
+            .overrideConfigKey("quarkus.micrometer.binder.jvm", "true")
             .overrideConfigKey("quarkus.micrometer.export.prometheus.enabled", "true")
             .overrideConfigKey("quarkus.micrometer.export.prometheus.default-registry", "false")
             .overrideConfigKey("quarkus.micrometer.registry-enabled-default", "false")
@@ -50,6 +51,9 @@ public void testMeterRegistryPresent() {
         Assertions.assertEquals(subPromRegistry, promRegistry,
                 "Should be the same bean as the PrometheusMeterRegistry. Found " + subRegistries);
 
+        Assertions.assertNotNull(registry.find("jvm.info").counter(),
+                "JVM Info counter should be present, found: " + registry.getMeters());
+
         String result = promRegistry.scrape();
         Assertions.assertTrue(result.contains("customKey=\\"customValue\\""),
                 "Scrape result should contain common tags from the custom registry configuration. Found\\n" + result);
diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/MicrometerRecorder.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/MicrometerRecorder.java
index fa61d99a6e3..bc58d9d1329 100644
--- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/MicrometerRecorder.java
+++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/MicrometerRecorder.java
@@ -104,7 +104,7 @@ public void configureRegistries(MicrometerConfig config,
         }
 
         // Base JVM Metrics
-        if (config.binder.jvm) {
+        if (config.checkBinderEnabledWithDefault(() -> config.binder.jvm)) {
             new ClassLoaderMetrics().bindTo(Metrics.globalRegistry);
             new JvmHeapPressureMetrics().bindTo(Metrics.globalRegistry);
             new JvmMemoryMetrics().bindTo(Metrics.globalRegistry);
@@ -115,8 +115,8 @@ public void configureRegistries(MicrometerConfig config,
             }
         }
 
-        // System
-        if (config.binder.system) {
+        // System metrics
+        if (config.checkBinderEnabledWithDefault(() -> config.binder.system)) {
             new UptimeMetrics().bindTo(Metrics.globalRegistry);
             new ProcessorMetrics().bindTo(Metrics.globalRegistry);
             new FileDescriptorMetrics().bindTo(Metrics.globalRegistry);
diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/MicrometerConfig.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/MicrometerConfig.java
index 0ec10d0f951..a32f88f2d8c 100644
--- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/MicrometerConfig.java
+++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/MicrometerConfig.java
@@ -97,10 +97,12 @@ public static class BinderConfig {
         /**
          * Micrometer JVM metrics support.
          * <p>
-         * Micrometer JVM metrics support is enabled by default.
+         * Support for JVM metrics will be enabled if Micrometer
+         * support is enabled, and either this value is true, or this
+         * value is unset and {@code quarkus.micrometer.binder-enabled-default} is true.
          */
-        @ConfigItem(defaultValue = "true")
-        public boolean jvm;
+        @ConfigItem
+        public Optional<Boolean> jvm;
 
         public KafkaConfigGroup kafka;
         public MPMetricsConfigGroup mpMetrics;
@@ -108,10 +110,12 @@ public static class BinderConfig {
         /**
          * Micrometer System metrics support.
          * <p>
-         * Micrometer System metrics support is enabled by default.
+         * Support for System metrics will be enabled if Micrometer
+         * support is enabled, and either this value is true, or this
+         * value is unset and {@code quarkus.micrometer.binder-enabled-default} is true.
          */
-        @ConfigItem(defaultValue = "true")
-        public boolean system;
+        @ConfigItem
+        public Optional<Boolean> system;
 
         public VertxConfigGroup vertx;
     }