autoCloseables = new ArrayList<>();
// Base JVM Metrics
- if (config.checkBinderEnabledWithDefault(() -> config.binder.jvm)) {
+ if (config.checkBinderEnabledWithDefault(() -> config.binder().jvm())) {
new ClassLoaderMetrics().bindTo(Metrics.globalRegistry);
JvmHeapPressureMetrics jvmHeapPressureMetrics = new JvmHeapPressureMetrics();
jvmHeapPressureMetrics.bindTo(Metrics.globalRegistry);
@@ -131,7 +131,7 @@ public void configureRegistries(MicrometerConfig config,
}
// System metrics
- if (config.checkBinderEnabledWithDefault(() -> config.binder.system)) {
+ 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/binder/HttpBinderConfiguration.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/HttpBinderConfiguration.java
index e9b3138571cf4..076589fd59253 100644
--- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/HttpBinderConfiguration.java
+++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/HttpBinderConfiguration.java
@@ -50,8 +50,8 @@ public HttpBinderConfiguration(boolean httpServerMetrics, boolean httpClientMetr
serverEnabled = httpServerMetrics;
clientEnabled = httpClientMetrics;
- serverSuppress4xxErrors = serverConfig.suppress4xxErrors;
- clientSuppress4xxErrors = clientConfig.suppress4xxErrors;
+ serverSuppress4xxErrors = serverConfig.suppress4xxErrors();
+ clientSuppress4xxErrors = clientConfig.suppress4xxErrors();
if (serverEnabled) {
Pattern defaultIgnore = null;
@@ -59,7 +59,7 @@ public HttpBinderConfiguration(boolean httpServerMetrics, boolean httpClientMetr
if (MicrometerRecorder.httpRootUri.equals(MicrometerRecorder.nonApplicationUri)) {
// we can't set the default ignore in this case, as the paths overlap
- } else if (serverConfig.suppressNonApplicationUris) {
+ } else if (serverConfig.suppressNonApplicationUris()) {
defaultIgnore = Pattern.compile(MicrometerRecorder.nonApplicationUri + ".*");
}
@@ -72,16 +72,16 @@ public HttpBinderConfiguration(boolean httpServerMetrics, boolean httpClientMetr
// Handle deprecated/previous vertx properties as well
serverIgnorePatterns = getIgnorePatterns(
- serverConfig.ignorePatterns.isPresent() ? serverConfig.ignorePatterns : vertxConfig.ignorePatterns,
+ serverConfig.ignorePatterns().isPresent() ? serverConfig.ignorePatterns() : vertxConfig.ignorePatterns(),
defaultIgnore);
serverMatchPatterns = getMatchPatterns(
- serverConfig.matchPatterns.isPresent() ? serverConfig.matchPatterns : vertxConfig.matchPatterns,
+ serverConfig.matchPatterns().isPresent() ? serverConfig.matchPatterns() : vertxConfig.matchPatterns(),
defaultMatch);
}
if (clientEnabled) {
- clientIgnorePatterns = getIgnorePatterns(clientConfig.ignorePatterns, null);
- clientMatchPatterns = getMatchPatterns(clientConfig.matchPatterns, null);
+ clientIgnorePatterns = getIgnorePatterns(clientConfig.ignorePatterns(), null);
+ clientMatchPatterns = getMatchPatterns(clientConfig.matchPatterns(), null);
}
}
diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/HttpMeterFilterProvider.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/HttpMeterFilterProvider.java
index ee2c3ef86b7ab..c3577e2f11ed9 100644
--- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/HttpMeterFilterProvider.java
+++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/HttpMeterFilterProvider.java
@@ -22,7 +22,7 @@ public class HttpMeterFilterProvider {
public MeterFilter metricsHttpClientUriTagFilter(HttpClientConfig httpClientConfig) {
if (binderConfiguration.isClientEnabled()) {
return maximumAllowableUriTagsFilter(binderConfiguration.getHttpClientRequestsName(),
- httpClientConfig.maxUriTags);
+ httpClientConfig.maxUriTags());
}
return null;
}
@@ -32,7 +32,7 @@ public MeterFilter metricsHttpClientUriTagFilter(HttpClientConfig httpClientConf
public MeterFilter metricsHttpServerUriTagFilter(HttpServerConfig httpServerConfig) {
if (binderConfiguration.isServerEnabled()) {
return maximumAllowableUriTagsFilter(binderConfiguration.getHttpServerRequestsName(),
- httpServerConfig.maxUriTags);
+ httpServerConfig.maxUriTags().getAsInt());
}
return null;
}
@@ -42,7 +42,7 @@ public MeterFilter metricsHttpServerUriTagFilter(HttpServerConfig httpServerConf
public MeterFilter metricsHttpPushUriTagFilter(HttpServerConfig httpServerConfig) {
if (binderConfiguration.isServerEnabled()) {
return maximumAllowableUriTagsFilter(binderConfiguration.getHttpServerPushName(),
- httpServerConfig.maxUriTags);
+ httpServerConfig.maxUriTags().getAsInt());
}
return null;
}
@@ -52,7 +52,7 @@ public MeterFilter metricsHttpPushUriTagFilter(HttpServerConfig httpServerConfig
public MeterFilter metricsHttpWebSocketsUriTagFilter(HttpServerConfig httpServerConfig) {
if (binderConfiguration.isServerEnabled()) {
return maximumAllowableUriTagsFilter(binderConfiguration.getHttpServerWebSocketConnectionsName(),
- httpServerConfig.maxUriTags);
+ httpServerConfig.maxUriTags().getAsInt());
}
return null;
}
diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/virtualthreads/VirtualThreadCollector.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/virtualthreads/VirtualThreadCollector.java
index 8503e03669842..d8b50dbe023a0 100644
--- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/virtualthreads/VirtualThreadCollector.java
+++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/virtualthreads/VirtualThreadCollector.java
@@ -40,7 +40,7 @@ public class VirtualThreadCollector {
@Inject
public VirtualThreadCollector(MicrometerConfig mc) {
- var config = mc.binder.virtualThreads;
+ var config = mc.binder().virtualThreads();
this.enabled = JavaVersionUtil.isJava21OrHigher() && config.enabled.orElse(true);
MeterBinder instantiated = null;
if (enabled) {
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 b5c51a3f002fb..2b26b7d776e17 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
@@ -3,23 +3,25 @@
import java.util.Optional;
import io.quarkus.runtime.annotations.ConfigGroup;
-import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
+import io.smallrye.config.ConfigMapping;
+import io.smallrye.config.WithDefault;
/**
* Global configuration for the Micrometer extension
*/
-@ConfigRoot(name = "micrometer", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
-public final class MicrometerConfig {
+@ConfigMapping(prefix = "quarkus.micrometer")
+@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
+public interface MicrometerConfig {
/**
* Micrometer metrics support.
*
* Micrometer metrics support is enabled by default.
*/
- @ConfigItem(defaultValue = "true")
- public boolean enabled;
+ @WithDefault("true")
+ boolean enabled();
/**
* Micrometer MeterRegistry discovery.
@@ -27,8 +29,8 @@ public final class MicrometerConfig {
* Micrometer MeterRegistry implementations discovered on the classpath
* will be enabled automatically by default.
*/
- @ConfigItem(defaultValue = "true")
- public boolean registryEnabledDefault;
+ @WithDefault("true")
+ boolean registryEnabledDefault();
/**
* Micrometer MeterBinder discovery.
@@ -36,24 +38,24 @@ public final class MicrometerConfig {
* Micrometer MeterBinder implementations discovered on the classpath
* will be enabled automatically by default.
*/
- @ConfigItem(defaultValue = "true")
- public boolean binderEnabledDefault;
+ @WithDefault("true")
+ boolean binderEnabledDefault();
/** Build / static runtime config for binders */
- public BinderConfig binder;
+ BinderConfig binder();
/** Build / static runtime config for exporters */
- public ExportConfig export;
+ ExportConfig export();
/**
* For MeterRegistry configurations with optional 'enabled' attributes,
* determine whether the registry is enabled using {@link #registryEnabledDefault}
* as the default value.
*/
- public boolean checkRegistryEnabledWithDefault(CapabilityEnabled config) {
- if (enabled) {
+ default boolean checkRegistryEnabledWithDefault(CapabilityEnabled config) {
+ if (enabled()) {
Optional configValue = config.getEnabled();
- return configValue.orElseGet(() -> registryEnabledDefault);
+ return configValue.orElseGet(this::registryEnabledDefault);
}
return false;
}
@@ -63,28 +65,20 @@ public boolean checkRegistryEnabledWithDefault(CapabilityEnabled config) {
* determine whether the binder is enabled using {@link #binderEnabledDefault}
* as the default value.
*/
- public boolean checkBinderEnabledWithDefault(CapabilityEnabled config) {
- if (enabled) {
+ default boolean checkBinderEnabledWithDefault(CapabilityEnabled config) {
+ if (enabled()) {
Optional configValue = config.getEnabled();
- return configValue.orElseGet(() -> binderEnabledDefault);
+ return configValue.orElseGet(this::binderEnabledDefault);
}
return false;
}
- @Override
- public String toString() {
- return this.getClass().getSimpleName()
- + "{enabled=" + enabled
- + ",binderEnabledDefault=" + binderEnabledDefault
- + ",registryEnabledDefault=" + registryEnabledDefault
- + '}';
- }
-
/** Build / static runtime config for binders */
@ConfigGroup
- public static class BinderConfig {
- public HttpClientConfigGroup httpClient;
- public HttpServerConfigGroup httpServer;
+ interface BinderConfig {
+ HttpClientConfigGroup httpClient();
+
+ HttpServerConfigGroup httpServer();
/**
* Micrometer JVM metrics support.
@@ -93,23 +87,23 @@ public static class BinderConfig {
* support is enabled, and either this value is true, or this
* value is unset and {@code quarkus.micrometer.binder-enabled-default} is true.
*/
- @ConfigItem
- public Optional jvm;
+ Optional jvm();
- public KafkaConfigGroup kafka;
+ KafkaConfigGroup kafka();
- public RedisConfigGroup redis;
- public StorkConfigGroup stork;
+ RedisConfigGroup redis();
- public GrpcServerConfigGroup grpcServer;
+ StorkConfigGroup stork();
- public GrpcClientConfigGroup grpcClient;
+ GrpcServerConfigGroup grpcServer();
- public ReactiveMessagingConfigGroup messaging;
+ GrpcClientConfigGroup grpcClient();
- public MPMetricsConfigGroup mpMetrics;
+ ReactiveMessagingConfigGroup messaging();
- public VirtualThreadsConfigGroup virtualThreads;
+ MPMetricsConfigGroup mpMetrics();
+
+ VirtualThreadsConfigGroup virtualThreads();
/**
* Micrometer System metrics support.
@@ -118,22 +112,22 @@ public static class BinderConfig {
* support is enabled, and either this value is true, or this
* value is unset and {@code quarkus.micrometer.binder-enabled-default} is true.
*/
- @ConfigItem
- public Optional system;
+ Optional system();
- public VertxConfigGroup vertx;
+ VertxConfigGroup vertx();
- public NettyConfigGroup netty;
+ NettyConfigGroup netty();
}
/** Build / static runtime config for exporters */
@ConfigGroup
- public static class ExportConfig {
- public JsonConfigGroup json;
- public PrometheusConfigGroup prometheus;
+ interface ExportConfig {
+ JsonConfigGroup json();
+
+ PrometheusConfigGroup prometheus();
}
- public interface CapabilityEnabled {
+ interface CapabilityEnabled {
Optional getEnabled();
}
}
diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/HttpClientConfig.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/HttpClientConfig.java
index 1adb307cad8c9..283cff3ba74ad 100644
--- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/HttpClientConfig.java
+++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/HttpClientConfig.java
@@ -3,12 +3,14 @@
import java.util.List;
import java.util.Optional;
-import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
+import io.smallrye.config.ConfigMapping;
+import io.smallrye.config.WithDefault;
-@ConfigRoot(name = "micrometer.binder.http-client", phase = ConfigPhase.RUN_TIME)
-public class HttpClientConfig {
+@ConfigMapping(prefix = "quarkus.micrometer.binder.http-client")
+@ConfigRoot(phase = ConfigPhase.RUN_TIME)
+public interface HttpClientConfig {
/**
* Comma-separated list of regular expressions used to specify uri
* labels in http metrics.
@@ -28,15 +30,13 @@ public class HttpClientConfig {
*
* @asciidoclet
*/
- @ConfigItem
- public Optional> matchPatterns = Optional.empty();
+ Optional> matchPatterns();
/**
* Comma-separated list of regular expressions defining uri paths
* that should be ignored (not measured).
*/
- @ConfigItem
- public Optional> ignorePatterns = Optional.empty();
+ Optional> ignorePatterns();
/**
* Suppress 4xx errors from metrics collection for unmatched templates.
@@ -46,14 +46,14 @@ public class HttpClientConfig {
*
* @asciidoclet
*/
- @ConfigItem(defaultValue = "false")
- public boolean suppress4xxErrors;
+ @WithDefault("false")
+ boolean suppress4xxErrors();
/**
* Maximum number of unique URI tag values allowed. After the max number of
* tag values is reached, metrics with additional tag values are denied by
* filter.
*/
- @ConfigItem(defaultValue = "100")
- public int maxUriTags;
+ @WithDefault("100")
+ int maxUriTags();
}
diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/HttpServerConfig.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/HttpServerConfig.java
index f9342aa1dc5d6..669295aebdc53 100644
--- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/HttpServerConfig.java
+++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/HttpServerConfig.java
@@ -2,13 +2,16 @@
import java.util.List;
import java.util.Optional;
+import java.util.OptionalInt;
-import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
+import io.smallrye.config.ConfigMapping;
+import io.smallrye.config.WithDefault;
-@ConfigRoot(name = "micrometer.binder.http-server", phase = ConfigPhase.RUN_TIME)
-public class HttpServerConfig {
+@ConfigMapping(prefix = "quarkus.micrometer.binder.http-server")
+@ConfigRoot(phase = ConfigPhase.RUN_TIME)
+public interface HttpServerConfig {
/**
* Comma-separated list of regular expressions used to specify uri
* labels in http metrics.
@@ -28,15 +31,13 @@ public class HttpServerConfig {
*
* @asciidoclet
*/
- @ConfigItem
- public Optional> matchPatterns = Optional.empty();
+ Optional> matchPatterns();
/**
* Comma-separated list of regular expressions defining uri paths
* that should be ignored (not measured).
*/
- @ConfigItem
- public Optional> ignorePatterns = Optional.empty();
+ Optional> ignorePatterns();
/**
* Suppress non-application uris from metrics collection.
@@ -47,8 +48,8 @@ public class HttpServerConfig {
*
* @asciidoclet
*/
- @ConfigItem(defaultValue = "true")
- public boolean suppressNonApplicationUris;
+ @WithDefault("true")
+ boolean suppressNonApplicationUris();
/**
* Suppress 4xx errors from metrics collection for unmatched templates.
@@ -58,23 +59,23 @@ public class HttpServerConfig {
*
* @asciidoclet
*/
- @ConfigItem(defaultValue = "false")
- public boolean suppress4xxErrors;
+ @WithDefault("false")
+ boolean suppress4xxErrors();
/**
* Maximum number of unique URI tag values allowed. After the max number of
* tag values is reached, metrics with additional tag values are denied by
* filter.
*/
- @ConfigItem(defaultValue = "100")
- public int maxUriTags;
+ @WithDefault("100")
+ OptionalInt maxUriTags();
- public void mergeDeprecatedConfig(VertxConfig config) {
- if (!ignorePatterns.isPresent()) {
- ignorePatterns = config.ignorePatterns;
- }
- if (!matchPatterns.isPresent()) {
- matchPatterns = config.matchPatterns;
- }
+ default void mergeDeprecatedConfig(VertxConfig config) {
+ // if (!ignorePatterns().isPresent()) {
+ // ignorePatterns = config.ignorePatterns;
+ // }
+ // if (!matchPatterns().isPresent()) {
+ // matchPatterns = config.matchPatterns;
+ // }
}
}
diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/PrometheusRuntimeConfig.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/PrometheusRuntimeConfig.java
index c4ce90f86b6d1..dd7ab7c41f122 100644
--- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/PrometheusRuntimeConfig.java
+++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/PrometheusRuntimeConfig.java
@@ -3,16 +3,18 @@
import java.util.Map;
import io.quarkus.runtime.annotations.ConfigDocMapKey;
-import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
+import io.smallrye.config.ConfigMapping;
+import io.smallrye.config.WithParentName;
/**
* Runtime configuration for Micrometer meter registries.
*/
@SuppressWarnings("unused")
-@ConfigRoot(name = "micrometer.export.prometheus", phase = ConfigPhase.RUN_TIME)
-public class PrometheusRuntimeConfig {
+@ConfigMapping(prefix = "quarkus.micrometer.export.prometheus")
+@ConfigRoot(phase = ConfigPhase.RUN_TIME)
+public interface PrometheusRuntimeConfig {
// @formatter:off
/**
* Prometheus registry configuration properties.
@@ -23,7 +25,7 @@ public class PrometheusRuntimeConfig {
* @asciidoclet
*/
// @formatter:on
- @ConfigItem(name = ConfigItem.PARENT)
+ @WithParentName
@ConfigDocMapKey("configuration-property-name")
- public Map prometheus;
+ Map prometheus();
}
diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/VertxConfig.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/VertxConfig.java
index cbe2a88135ec1..1174bf4270a6d 100644
--- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/VertxConfig.java
+++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/config/runtime/VertxConfig.java
@@ -3,18 +3,18 @@
import java.util.List;
import java.util.Optional;
-import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
+import io.smallrye.config.ConfigMapping;
-@ConfigRoot(name = "micrometer.binder.vertx", phase = ConfigPhase.RUN_TIME)
-public class VertxConfig {
+@ConfigMapping(prefix = "quarkus.micrometer.binder.vertx")
+@ConfigRoot(phase = ConfigPhase.RUN_TIME)
+public interface VertxConfig {
/**
* @deprecated use {@code quarkus.micrometer.binder.http-server.match-patterns}
*/
@Deprecated
- @ConfigItem
- public Optional> matchPatterns = Optional.empty();
+ Optional> matchPatterns();
/**
* Comma-separated list of regular expressions defining uri paths
@@ -23,6 +23,5 @@ public class VertxConfig {
* @deprecated use {@code quarkus.micrometer.binder.http-server.ignore-patterns}
*/
@Deprecated
- @ConfigItem
- public Optional> ignorePatterns = Optional.empty();
+ Optional> ignorePatterns();
}
diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/JsonMeterRegistryProvider.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/JsonMeterRegistryProvider.java
index 1c0d662130d98..25d1fef7bad29 100644
--- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/JsonMeterRegistryProvider.java
+++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/JsonMeterRegistryProvider.java
@@ -12,6 +12,6 @@ public class JsonMeterRegistryProvider {
@Produces
@Singleton
public JsonMeterRegistry registry(Clock clock, io.quarkus.micrometer.runtime.config.MicrometerConfig config) {
- return new JsonMeterRegistry(clock, config.export.json.bufferLength, config.export.json.expiry);
+ return new JsonMeterRegistry(clock, config.export().json().bufferLength, config.export().json().expiry);
}
}
diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/PrometheusMeterRegistryProvider.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/PrometheusMeterRegistryProvider.java
index b1cef90873d27..641932a08463d 100644
--- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/PrometheusMeterRegistryProvider.java
+++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/PrometheusMeterRegistryProvider.java
@@ -21,7 +21,7 @@ public class PrometheusMeterRegistryProvider {
@Singleton
@DefaultBean
public PrometheusConfig configure(PrometheusRuntimeConfig config) {
- final Map properties = ConfigAdapter.captureProperties(config.prometheus, PREFIX);
+ final Map properties = ConfigAdapter.captureProperties(config.prometheus(), PREFIX);
return ConfigAdapter.validate(properties::get);
}
diff --git a/extensions/micrometer/runtime/src/test/java/io/quarkus/micrometer/runtime/binder/HttpBinderConfigurationTest.java b/extensions/micrometer/runtime/src/test/java/io/quarkus/micrometer/runtime/binder/HttpBinderConfigurationTest.java
index a9e7722b85922..0fdddb63e1d50 100644
--- a/extensions/micrometer/runtime/src/test/java/io/quarkus/micrometer/runtime/binder/HttpBinderConfigurationTest.java
+++ b/extensions/micrometer/runtime/src/test/java/io/quarkus/micrometer/runtime/binder/HttpBinderConfigurationTest.java
@@ -10,6 +10,7 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
import io.quarkus.micrometer.runtime.config.runtime.HttpClientConfig;
import io.quarkus.micrometer.runtime.config.runtime.HttpServerConfig;
@@ -18,12 +19,15 @@
public class HttpBinderConfigurationTest {
@Test
public void testHttpServerMetricsIgnorePatterns() {
- HttpServerConfig serverConfig = new HttpServerConfig();
- serverConfig.ignorePatterns = Optional.of(new ArrayList<>(Arrays.asList(" /item/.* ", " /oranges/.* ")));
-
+ HttpServerConfig httpServerConfig = Mockito.mock(HttpServerConfig.class);
+ Mockito.doReturn(Optional.of(new ArrayList<>(Arrays.asList(" /item/.* ", " /oranges/.* "))))
+ .when(httpServerConfig)
+ .ignorePatterns();
+ VertxConfig vertxConfig = Mockito.mock(VertxConfig.class);
+ HttpClientConfig httpClientConfig = Mockito.mock(HttpClientConfig.class);
HttpBinderConfiguration binderConfig = new HttpBinderConfiguration(
true, false,
- serverConfig, new HttpClientConfig(), new VertxConfig());
+ httpServerConfig, httpClientConfig, vertxConfig);
List ignorePatterns = binderConfig.getServerIgnorePatterns();
Assertions.assertEquals(2, ignorePatterns.size());
@@ -39,13 +43,15 @@ public void testHttpServerMetricsIgnorePatterns() {
@Test
public void testHttpServerMetricsMatchPatterns() {
- HttpServerConfig serverConfig = new HttpServerConfig();
- serverConfig.matchPatterns = Optional
- .of(new ArrayList<>(Arrays.asList(" /item/\\d+=/item/{id} ", " /msg/\\d+=/msg/{other} ")));
-
+ HttpServerConfig httpServerConfig = Mockito.mock(HttpServerConfig.class);
+ Mockito.doReturn(Optional
+ .of(new ArrayList<>(Arrays.asList(" /item/\\d+=/item/{id} ", " /msg/\\d+=/msg/{other} "))))
+ .when(httpServerConfig).matchPatterns();
+ HttpClientConfig httpClientConfig = Mockito.mock(HttpClientConfig.class);
+ VertxConfig vertxConfig = Mockito.mock(VertxConfig.class);
HttpBinderConfiguration binderConfig = new HttpBinderConfiguration(
true, false,
- serverConfig, new HttpClientConfig(), new VertxConfig());
+ httpServerConfig, httpClientConfig, vertxConfig);
Map matchPatterns = binderConfig.getServerMatchPatterns();
Assertions.assertFalse(matchPatterns.isEmpty());
diff --git a/extensions/micrometer/runtime/src/test/java/io/quarkus/micrometer/runtime/binder/RequestMetricInfoTest.java b/extensions/micrometer/runtime/src/test/java/io/quarkus/micrometer/runtime/binder/RequestMetricInfoTest.java
index cc2b63d2da680..08d3c5cea3020 100644
--- a/extensions/micrometer/runtime/src/test/java/io/quarkus/micrometer/runtime/binder/RequestMetricInfoTest.java
+++ b/extensions/micrometer/runtime/src/test/java/io/quarkus/micrometer/runtime/binder/RequestMetricInfoTest.java
@@ -13,6 +13,7 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
import io.quarkus.micrometer.runtime.config.runtime.HttpClientConfig;
import io.quarkus.micrometer.runtime.config.runtime.HttpServerConfig;
@@ -59,13 +60,14 @@ public void testParsePathIgnoreNoLeadingSlash() {
@Test
public void testHttpServerMetricsIgnorePatterns() {
- HttpServerConfig serverConfig = new HttpServerConfig();
- serverConfig.ignorePatterns = Optional.of(new ArrayList<>(Arrays.asList(" /item/.* ", " /oranges/.* ")));
-
+ HttpServerConfig httpServerConfig = Mockito.mock(HttpServerConfig.class);
+ Mockito.doReturn(Optional.of(new ArrayList<>(Arrays.asList(" /item/.* ", " /oranges/.* "))))
+ .when(httpServerConfig).ignorePatterns();
+ HttpClientConfig httpClientConfig = Mockito.mock(HttpClientConfig.class);
+ VertxConfig vertxConfig = Mockito.mock(VertxConfig.class);
HttpBinderConfiguration binderConfig = new HttpBinderConfiguration(
true, false,
- serverConfig, new HttpClientConfig(), new VertxConfig());
-
+ httpServerConfig, httpClientConfig, vertxConfig);
Assertions.assertEquals(2, binderConfig.serverIgnorePatterns.size());
Pattern p = binderConfig.serverIgnorePatterns.get(0);
@@ -97,13 +99,16 @@ public void testParsePathMatchReplaceLeadingSlash() {
@Test
public void testHttpServerMetricsMatchPatterns() {
- HttpServerConfig serverConfig = new HttpServerConfig();
- serverConfig.matchPatterns = Optional
- .of(new ArrayList<>(Arrays.asList(" /item/\\d+=/item/{id} ", " /msg/\\d+=/msg/{other} ")));
+ HttpServerConfig httpServerConfig = Mockito.mock(HttpServerConfig.class);
+ Mockito.doReturn(Optional
+ .of(new ArrayList<>(Arrays.asList(" /item/\\d+=/item/{id} ", " /msg/\\d+=/msg/{other} "))))
+ .when(httpServerConfig).ignorePatterns();
+ HttpClientConfig httpClientConfig = Mockito.mock(HttpClientConfig.class);
+ VertxConfig vertxConfig = Mockito.mock(VertxConfig.class);
HttpBinderConfiguration binderConfig = new HttpBinderConfiguration(
true, false,
- serverConfig, new HttpClientConfig(), new VertxConfig());
+ httpServerConfig, httpClientConfig, vertxConfig);
Assertions.assertFalse(binderConfig.serverMatchPatterns.isEmpty());
Iterator> i = binderConfig.serverMatchPatterns.entrySet().iterator();