Start building against Micrometer 1.9.0-M4 snapshots

Micrometer duplicated the binders in a separate module named
micrometer-binders, and marked the binders in the core module as
deprecated. This commit changes the imports to use the new binders in
the micrometer-binders module. Additionally, the auto-configurations
honor user-supplied beans which use the old binders in the
micrometer-core module.

See gh-30014
pull/30078/head
Moritz Halbritter 3 years ago
parent 74726bddcf
commit 7897a913a7

@ -48,6 +48,7 @@ dependencies {
optional("io.dropwizard.metrics:metrics-jmx") optional("io.dropwizard.metrics:metrics-jmx")
optional("io.lettuce:lettuce-core") optional("io.lettuce:lettuce-core")
optional("io.micrometer:micrometer-core") optional("io.micrometer:micrometer-core")
optional("io.micrometer:micrometer-binders")
optional("io.micrometer:micrometer-registry-appoptics") optional("io.micrometer:micrometer-registry-appoptics")
optional("io.micrometer:micrometer-registry-atlas") { optional("io.micrometer:micrometer-registry-atlas") {
exclude group: "javax.inject", module: "javax.inject" exclude group: "javax.inject", module: "javax.inject"

@ -16,12 +16,12 @@
package org.springframework.boot.actuate.autoconfigure.metrics; package org.springframework.boot.actuate.autoconfigure.metrics;
import io.micrometer.binder.jvm.ClassLoaderMetrics;
import io.micrometer.binder.jvm.JvmGcMetrics;
import io.micrometer.binder.jvm.JvmHeapPressureMetrics;
import io.micrometer.binder.jvm.JvmMemoryMetrics;
import io.micrometer.binder.jvm.JvmThreadMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmHeapPressureMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -42,31 +42,35 @@ import org.springframework.context.annotation.Bean;
public class JvmMetricsAutoConfiguration { public class JvmMetricsAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean({ JvmGcMetrics.class, io.micrometer.core.instrument.binder.jvm.JvmGcMetrics.class })
public JvmGcMetrics jvmGcMetrics() { public JvmGcMetrics jvmGcMetrics() {
return new JvmGcMetrics(); return new JvmGcMetrics();
} }
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean({ JvmHeapPressureMetrics.class,
io.micrometer.core.instrument.binder.jvm.JvmHeapPressureMetrics.class })
public JvmHeapPressureMetrics jvmHeapPressureMetrics() { public JvmHeapPressureMetrics jvmHeapPressureMetrics() {
return new JvmHeapPressureMetrics(); return new JvmHeapPressureMetrics();
} }
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean({ JvmMemoryMetrics.class,
io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics.class })
public JvmMemoryMetrics jvmMemoryMetrics() { public JvmMemoryMetrics jvmMemoryMetrics() {
return new JvmMemoryMetrics(); return new JvmMemoryMetrics();
} }
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean({ JvmThreadMetrics.class,
io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics.class })
public JvmThreadMetrics jvmThreadMetrics() { public JvmThreadMetrics jvmThreadMetrics() {
return new JvmThreadMetrics(); return new JvmThreadMetrics();
} }
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean({ ClassLoaderMetrics.class,
io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics.class })
public ClassLoaderMetrics classLoaderMetrics() { public ClassLoaderMetrics classLoaderMetrics() {
return new ClassLoaderMetrics(); return new ClassLoaderMetrics();
} }

@ -16,9 +16,9 @@
package org.springframework.boot.actuate.autoconfigure.metrics; package org.springframework.boot.actuate.autoconfigure.metrics;
import io.micrometer.binder.kafka.KafkaClientMetrics;
import io.micrometer.binder.kafka.KafkaStreamsMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.kafka.KafkaClientMetrics;
import io.micrometer.core.instrument.binder.kafka.KafkaStreamsMetrics;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;

@ -16,8 +16,8 @@
package org.springframework.boot.actuate.autoconfigure.metrics; package org.springframework.boot.actuate.autoconfigure.metrics;
import io.micrometer.binder.logging.Log4j2Metrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.logging.Log4j2Metrics;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.spi.LoggerContext; import org.apache.logging.log4j.spi.LoggerContext;
@ -47,7 +47,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
public class Log4J2MetricsAutoConfiguration { public class Log4J2MetricsAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean({ Log4j2Metrics.class, io.micrometer.core.instrument.binder.logging.Log4j2Metrics.class })
public Log4j2Metrics log4j2Metrics() { public Log4j2Metrics log4j2Metrics() {
return new Log4j2Metrics(); return new Log4j2Metrics();
} }

@ -17,8 +17,8 @@
package org.springframework.boot.actuate.autoconfigure.metrics; package org.springframework.boot.actuate.autoconfigure.metrics;
import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.LoggerContext;
import io.micrometer.binder.logging.LogbackMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.logging.LogbackMetrics;
import org.slf4j.ILoggerFactory; import org.slf4j.ILoggerFactory;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -49,7 +49,8 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
public class LogbackMetricsAutoConfiguration { public class LogbackMetricsAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean({ LogbackMetrics.class,
io.micrometer.core.instrument.binder.logging.LogbackMetrics.class })
public LogbackMetrics logbackMetrics() { public LogbackMetrics logbackMetrics() {
return new LogbackMetrics(); return new LogbackMetrics();
} }

@ -19,11 +19,11 @@ package org.springframework.boot.actuate.autoconfigure.metrics;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import io.micrometer.binder.system.FileDescriptorMetrics;
import io.micrometer.binder.system.ProcessorMetrics;
import io.micrometer.binder.system.UptimeMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tags; import io.micrometer.core.instrument.Tags;
import io.micrometer.core.instrument.binder.system.FileDescriptorMetrics;
import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
import io.micrometer.core.instrument.binder.system.UptimeMetrics;
import org.springframework.boot.actuate.metrics.system.DiskSpaceMetricsBinder; import org.springframework.boot.actuate.metrics.system.DiskSpaceMetricsBinder;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
@ -48,19 +48,21 @@ import org.springframework.context.annotation.Bean;
public class SystemMetricsAutoConfiguration { public class SystemMetricsAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean({ UptimeMetrics.class, io.micrometer.core.instrument.binder.system.UptimeMetrics.class })
public UptimeMetrics uptimeMetrics() { public UptimeMetrics uptimeMetrics() {
return new UptimeMetrics(); return new UptimeMetrics();
} }
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean({ ProcessorMetrics.class,
io.micrometer.core.instrument.binder.system.ProcessorMetrics.class })
public ProcessorMetrics processorMetrics() { public ProcessorMetrics processorMetrics() {
return new ProcessorMetrics(); return new ProcessorMetrics();
} }
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean({ FileDescriptorMetrics.class,
io.micrometer.core.instrument.binder.system.FileDescriptorMetrics.class })
public FileDescriptorMetrics fileDescriptorMetrics() { public FileDescriptorMetrics fileDescriptorMetrics() {
return new FileDescriptorMetrics(); return new FileDescriptorMetrics();
} }

@ -0,0 +1,43 @@
/*
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.actuate.autoconfigure.metrics.jersey;
import io.micrometer.binder.jersey.server.DefaultJerseyTagsProvider;
import io.micrometer.binder.jersey.server.JerseyTagsProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
/**
* Configurations, imported from {@link JerseyServerMetricsAutoConfiguration}.
*
* @author Moritz Halbritter
*/
abstract class JerseyConfigurations {
static class JerseyTagsProviderConfiguration {
@Bean
@ConditionalOnMissingBean({ JerseyTagsProvider.class,
io.micrometer.core.instrument.binder.jersey.server.JerseyTagsProvider.class })
DefaultJerseyTagsProvider jerseyTagsProvider() {
return new DefaultJerseyTagsProvider();
}
}
}

@ -19,11 +19,10 @@ package org.springframework.boot.actuate.autoconfigure.metrics.jersey;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement; import java.lang.reflect.AnnotatedElement;
import io.micrometer.binder.jersey.server.AnnotationFinder;
import io.micrometer.binder.jersey.server.JerseyTagsProvider;
import io.micrometer.binder.jersey.server.MetricsApplicationEventListener;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.jersey.server.AnnotationFinder;
import io.micrometer.core.instrument.binder.jersey.server.DefaultJerseyTagsProvider;
import io.micrometer.core.instrument.binder.jersey.server.JerseyTagsProvider;
import io.micrometer.core.instrument.binder.jersey.server.MetricsApplicationEventListener;
import io.micrometer.core.instrument.config.MeterFilter; import io.micrometer.core.instrument.config.MeterFilter;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
@ -32,15 +31,16 @@ import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties;
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties.Web.Server; import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties.Web.Server;
import org.springframework.boot.actuate.autoconfigure.metrics.OnlyOnceLoggingDenyMeterFilter; import org.springframework.boot.actuate.autoconfigure.metrics.OnlyOnceLoggingDenyMeterFilter;
import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.metrics.jersey.JerseyConfigurations.JerseyTagsProviderConfiguration;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.jersey.ResourceConfigCustomizer; import org.springframework.boot.autoconfigure.jersey.ResourceConfigCustomizer;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.AnnotationUtils; import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
@ -57,6 +57,7 @@ import org.springframework.core.annotation.Order;
@ConditionalOnClass({ ResourceConfig.class, MetricsApplicationEventListener.class }) @ConditionalOnClass({ ResourceConfig.class, MetricsApplicationEventListener.class })
@ConditionalOnBean({ MeterRegistry.class, ResourceConfig.class }) @ConditionalOnBean({ MeterRegistry.class, ResourceConfig.class })
@EnableConfigurationProperties(MetricsProperties.class) @EnableConfigurationProperties(MetricsProperties.class)
@Import(JerseyTagsProviderConfiguration.class)
public class JerseyServerMetricsAutoConfiguration { public class JerseyServerMetricsAutoConfiguration {
private final MetricsProperties properties; private final MetricsProperties properties;
@ -66,12 +67,7 @@ public class JerseyServerMetricsAutoConfiguration {
} }
@Bean @Bean
@ConditionalOnMissingBean(JerseyTagsProvider.class) @ConditionalOnBean(JerseyTagsProvider.class)
public DefaultJerseyTagsProvider jerseyTagsProvider() {
return new DefaultJerseyTagsProvider();
}
@Bean
public ResourceConfigCustomizer jerseyServerMetricsResourceConfigCustomizer(MeterRegistry meterRegistry, public ResourceConfigCustomizer jerseyServerMetricsResourceConfigCustomizer(MeterRegistry meterRegistry,
JerseyTagsProvider tagsProvider) { JerseyTagsProvider tagsProvider) {
Server server = this.properties.getWeb().getServer(); Server server = this.properties.getWeb().getServer();
@ -80,6 +76,19 @@ public class JerseyServerMetricsAutoConfiguration {
server.getRequest().getAutotime().isEnabled(), new AnnotationUtilsAnnotationFinder())); server.getRequest().getAutotime().isEnabled(), new AnnotationUtilsAnnotationFinder()));
} }
@Bean
@ConditionalOnBean(io.micrometer.core.instrument.binder.jersey.server.JerseyTagsProvider.class)
public ResourceConfigCustomizer jerseyServerMetricsResourceConfigCustomizerBackwardsCompatible(
MeterRegistry meterRegistry,
io.micrometer.core.instrument.binder.jersey.server.JerseyTagsProvider tagsProvider) {
Server server = this.properties.getWeb().getServer();
return (config) -> config.register(
new io.micrometer.core.instrument.binder.jersey.server.MetricsApplicationEventListener(meterRegistry,
tagsProvider, server.getRequest().getMetricName(),
server.getRequest().getAutotime().isEnabled(),
new AnnotationUtilsAnnotationFinderBackwardsCompatible()));
}
@Bean @Bean
@Order(0) @Order(0)
public MeterFilter jerseyMetricsUriTagFilter() { public MeterFilter jerseyMetricsUriTagFilter() {
@ -102,4 +111,18 @@ public class JerseyServerMetricsAutoConfiguration {
} }
/**
* An {@link AnnotationFinder} (for backwards compatability) that uses
* {@link AnnotationUtils}.
*/
private static class AnnotationUtilsAnnotationFinderBackwardsCompatible
implements io.micrometer.core.instrument.binder.jersey.server.AnnotationFinder {
@Override
public <A extends Annotation> A findAnnotation(AnnotatedElement annotatedElement, Class<A> annotationType) {
return AnnotationUtils.findAnnotation(annotatedElement, annotationType);
}
}
} }

@ -0,0 +1,116 @@
/*
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.actuate.autoconfigure.metrics.mongo;
import io.micrometer.binder.mongodb.DefaultMongoCommandTagsProvider;
import io.micrometer.binder.mongodb.DefaultMongoConnectionPoolTagsProvider;
import io.micrometer.binder.mongodb.MongoCommandTagsProvider;
import io.micrometer.binder.mongodb.MongoMetricsCommandListener;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
/**
* Configurations, imported from {@link MongoMetricsAutoConfiguration}.
*
* @author Moritz Halbritter
*/
abstract class MongoConfigurations {
@Configuration(proxyBeanMethods = false)
static class MongoCommandTagsProviderConfiguration {
@Bean
@ConditionalOnMissingBean({ MongoCommandTagsProvider.class,
io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider.class })
MongoCommandTagsProvider mongoCommandTagsProvider() {
return new DefaultMongoCommandTagsProvider();
}
}
@Configuration(proxyBeanMethods = false)
@Import(MongoCommandTagsProviderConfiguration.class)
static class MongoMetricsCommandListenerConfiguration {
@Bean
@ConditionalOnMissingBean({ MongoMetricsCommandListener.class,
io.micrometer.core.instrument.binder.mongodb.MongoMetricsCommandListener.class })
@ConditionalOnBean(MongoCommandTagsProvider.class)
MongoMetricsCommandListener mongoMetricsCommandListener(MeterRegistry meterRegistry,
MongoCommandTagsProvider mongoCommandTagsProvider) {
return new MongoMetricsCommandListener(meterRegistry, mongoCommandTagsProvider);
}
@Bean
@ConditionalOnMissingBean({ MongoMetricsCommandListener.class,
io.micrometer.core.instrument.binder.mongodb.MongoMetricsCommandListener.class })
@ConditionalOnBean(io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider.class)
io.micrometer.core.instrument.binder.mongodb.MongoMetricsCommandListener mongoMetricsCommandListenerBackwardsCompatible(
MeterRegistry meterRegistry,
io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider mongoCommandTagsProvider) {
return new io.micrometer.core.instrument.binder.mongodb.MongoMetricsCommandListener(meterRegistry,
mongoCommandTagsProvider);
}
}
@Configuration(proxyBeanMethods = false)
static class MongoConnectionPoolTagsProviderConfiguration {
@Bean
@ConditionalOnMissingBean({ io.micrometer.binder.mongodb.MongoConnectionPoolTagsProvider.class,
io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider.class })
io.micrometer.binder.mongodb.MongoConnectionPoolTagsProvider mongoConnectionPoolTagsProvider() {
return new DefaultMongoConnectionPoolTagsProvider();
}
}
@Configuration(proxyBeanMethods = false)
@Import(MongoConnectionPoolTagsProviderConfiguration.class)
static class MongoMetricsConnectionPoolListenerConfiguration {
@Bean
@ConditionalOnMissingBean({ io.micrometer.binder.mongodb.MongoMetricsConnectionPoolListener.class,
io.micrometer.core.instrument.binder.mongodb.MongoMetricsConnectionPoolListener.class })
@ConditionalOnBean(io.micrometer.binder.mongodb.MongoConnectionPoolTagsProvider.class)
io.micrometer.binder.mongodb.MongoMetricsConnectionPoolListener mongoMetricsConnectionPoolListener(
MeterRegistry meterRegistry,
io.micrometer.binder.mongodb.MongoConnectionPoolTagsProvider mongoConnectionPoolTagsProvider) {
return new io.micrometer.binder.mongodb.MongoMetricsConnectionPoolListener(meterRegistry,
mongoConnectionPoolTagsProvider);
}
@Bean
@ConditionalOnMissingBean({ io.micrometer.binder.mongodb.MongoMetricsConnectionPoolListener.class,
io.micrometer.core.instrument.binder.mongodb.MongoMetricsConnectionPoolListener.class })
@ConditionalOnBean(io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider.class)
io.micrometer.core.instrument.binder.mongodb.MongoMetricsConnectionPoolListener mongoMetricsConnectionPoolListenerBackwardsCompatible(
MeterRegistry meterRegistry,
io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider mongoConnectionPoolTagsProvider) {
return new io.micrometer.core.instrument.binder.mongodb.MongoMetricsConnectionPoolListener(meterRegistry,
mongoConnectionPoolTagsProvider);
}
}
}

@ -17,31 +17,31 @@
package org.springframework.boot.actuate.autoconfigure.metrics.mongo; package org.springframework.boot.actuate.autoconfigure.metrics.mongo;
import com.mongodb.MongoClientSettings; import com.mongodb.MongoClientSettings;
import io.micrometer.binder.mongodb.MongoMetricsCommandListener;
import io.micrometer.binder.mongodb.MongoMetricsConnectionPoolListener;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.mongodb.DefaultMongoCommandTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.DefaultMongoConnectionPoolTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsCommandListener;
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsConnectionPoolListener;
import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.metrics.mongo.MongoConfigurations.MongoMetricsCommandListenerConfiguration;
import org.springframework.boot.actuate.autoconfigure.metrics.mongo.MongoConfigurations.MongoMetricsConnectionPoolListenerConfiguration;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoClientSettingsBuilderCustomizer; import org.springframework.boot.autoconfigure.mongo.MongoClientSettingsBuilderCustomizer;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
/** /**
* {@link EnableAutoConfiguration Auto-configuration} for Mongo metrics. * {@link EnableAutoConfiguration Auto-configuration} for Mongo metrics.
* *
* @author Chris Bono * @author Chris Bono
* @author Jonatan Ivanov * @author Jonatan Ivanov
* @author Moritz Halbritter
* @since 2.5.0 * @since 2.5.0
*/ */
@AutoConfiguration(before = MongoAutoConfiguration.class, @AutoConfiguration(before = MongoAutoConfiguration.class,
@ -50,53 +50,49 @@ import org.springframework.context.annotation.Bean;
@ConditionalOnBean(MeterRegistry.class) @ConditionalOnBean(MeterRegistry.class)
public class MongoMetricsAutoConfiguration { public class MongoMetricsAutoConfiguration {
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(MongoMetricsCommandListener.class) @ConditionalOnClass(MongoMetricsCommandListener.class)
@ConditionalOnProperty(name = "management.metrics.mongo.command.enabled", havingValue = "true", @ConditionalOnProperty(name = "management.metrics.mongo.command.enabled", havingValue = "true",
matchIfMissing = true) matchIfMissing = true)
@Import(MongoMetricsCommandListenerConfiguration.class)
static class MongoCommandMetricsConfiguration { static class MongoCommandMetricsConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnBean(MongoMetricsCommandListener.class)
MongoMetricsCommandListener mongoMetricsCommandListener(MeterRegistry meterRegistry, MongoClientSettingsBuilderCustomizer mongoMetricsCommandListenerClientSettingsBuilderCustomizer(
MongoCommandTagsProvider mongoCommandTagsProvider) { MongoMetricsCommandListener mongoMetricsCommandListener) {
return new MongoMetricsCommandListener(meterRegistry, mongoCommandTagsProvider); return (clientSettingsBuilder) -> clientSettingsBuilder.addCommandListener(mongoMetricsCommandListener);
}
@Bean
@ConditionalOnMissingBean
MongoCommandTagsProvider mongoCommandTagsProvider() {
return new DefaultMongoCommandTagsProvider();
} }
@Bean @Bean
MongoClientSettingsBuilderCustomizer mongoMetricsCommandListenerClientSettingsBuilderCustomizer( @ConditionalOnBean(io.micrometer.core.instrument.binder.mongodb.MongoMetricsCommandListener.class)
MongoMetricsCommandListener mongoMetricsCommandListener) { MongoClientSettingsBuilderCustomizer mongoMetricsCommandListenerClientSettingsBuilderCustomizerBackwardsCompatible(
io.micrometer.core.instrument.binder.mongodb.MongoMetricsCommandListener mongoMetricsCommandListener) {
return (clientSettingsBuilder) -> clientSettingsBuilder.addCommandListener(mongoMetricsCommandListener); return (clientSettingsBuilder) -> clientSettingsBuilder.addCommandListener(mongoMetricsCommandListener);
} }
} }
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(MongoMetricsConnectionPoolListener.class) @ConditionalOnClass(MongoMetricsConnectionPoolListener.class)
@ConditionalOnProperty(name = "management.metrics.mongo.connectionpool.enabled", havingValue = "true", @ConditionalOnProperty(name = "management.metrics.mongo.connectionpool.enabled", havingValue = "true",
matchIfMissing = true) matchIfMissing = true)
@Import(MongoMetricsConnectionPoolListenerConfiguration.class)
static class MongoConnectionPoolMetricsConfiguration { static class MongoConnectionPoolMetricsConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnBean(MongoMetricsConnectionPoolListener.class)
MongoMetricsConnectionPoolListener mongoMetricsConnectionPoolListener(MeterRegistry meterRegistry, MongoClientSettingsBuilderCustomizer mongoMetricsConnectionPoolListenerClientSettingsBuilderCustomizer(
MongoConnectionPoolTagsProvider mongoConnectionPoolTagsProvider) { MongoMetricsConnectionPoolListener mongoMetricsConnectionPoolListener) {
return new MongoMetricsConnectionPoolListener(meterRegistry, mongoConnectionPoolTagsProvider); return (clientSettingsBuilder) -> clientSettingsBuilder
} .applyToConnectionPoolSettings((connectionPoolSettingsBuilder) -> connectionPoolSettingsBuilder
.addConnectionPoolListener(mongoMetricsConnectionPoolListener));
@Bean
@ConditionalOnMissingBean
MongoConnectionPoolTagsProvider mongoConnectionPoolTagsProvider() {
return new DefaultMongoConnectionPoolTagsProvider();
} }
@Bean @Bean
MongoClientSettingsBuilderCustomizer mongoMetricsConnectionPoolListenerClientSettingsBuilderCustomizer( @ConditionalOnBean(io.micrometer.core.instrument.binder.mongodb.MongoMetricsConnectionPoolListener.class)
MongoMetricsConnectionPoolListener mongoMetricsConnectionPoolListener) { MongoClientSettingsBuilderCustomizer mongoMetricsConnectionPoolListenerClientSettingsBuilderCustomizerBackwardsCompatible(
io.micrometer.core.instrument.binder.mongodb.MongoMetricsConnectionPoolListener mongoMetricsConnectionPoolListener) {
return (clientSettingsBuilder) -> clientSettingsBuilder return (clientSettingsBuilder) -> clientSettingsBuilder
.applyToConnectionPoolSettings((connectionPoolSettingsBuilder) -> connectionPoolSettingsBuilder .applyToConnectionPoolSettings((connectionPoolSettingsBuilder) -> connectionPoolSettingsBuilder
.addConnectionPoolListener(mongoMetricsConnectionPoolListener)); .addConnectionPoolListener(mongoMetricsConnectionPoolListener));

@ -21,8 +21,8 @@ import java.util.Map;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import io.micrometer.binder.jvm.ExecutorServiceMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.jvm.ExecutorServiceMetrics;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;

@ -16,10 +16,10 @@
package org.springframework.boot.actuate.autoconfigure.metrics.web.jetty; package org.springframework.boot.actuate.autoconfigure.metrics.web.jetty;
import io.micrometer.binder.jetty.JettyConnectionMetrics;
import io.micrometer.binder.jetty.JettyServerThreadPoolMetrics;
import io.micrometer.binder.jetty.JettySslHandshakeMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.jetty.JettyConnectionMetrics;
import io.micrometer.core.instrument.binder.jetty.JettyServerThreadPoolMetrics;
import io.micrometer.core.instrument.binder.jetty.JettySslHandshakeMetrics;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration;
@ -49,19 +49,25 @@ import org.springframework.context.annotation.Bean;
public class JettyMetricsAutoConfiguration { public class JettyMetricsAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean({ JettyServerThreadPoolMetrics.class, JettyServerThreadPoolMetricsBinder.class }) @ConditionalOnMissingBean({ JettyServerThreadPoolMetrics.class,
io.micrometer.core.instrument.binder.jetty.JettyServerThreadPoolMetrics.class,
JettyServerThreadPoolMetricsBinder.class })
public JettyServerThreadPoolMetricsBinder jettyServerThreadPoolMetricsBinder(MeterRegistry meterRegistry) { public JettyServerThreadPoolMetricsBinder jettyServerThreadPoolMetricsBinder(MeterRegistry meterRegistry) {
return new JettyServerThreadPoolMetricsBinder(meterRegistry); return new JettyServerThreadPoolMetricsBinder(meterRegistry);
} }
@Bean @Bean
@ConditionalOnMissingBean({ JettyConnectionMetrics.class, JettyConnectionMetricsBinder.class }) @ConditionalOnMissingBean({ JettyConnectionMetrics.class,
io.micrometer.core.instrument.binder.jetty.JettyConnectionMetrics.class,
JettyConnectionMetricsBinder.class })
public JettyConnectionMetricsBinder jettyConnectionMetricsBinder(MeterRegistry meterRegistry) { public JettyConnectionMetricsBinder jettyConnectionMetricsBinder(MeterRegistry meterRegistry) {
return new JettyConnectionMetricsBinder(meterRegistry); return new JettyConnectionMetricsBinder(meterRegistry);
} }
@Bean @Bean
@ConditionalOnMissingBean({ JettySslHandshakeMetrics.class, JettySslHandshakeMetricsBinder.class }) @ConditionalOnMissingBean({ JettySslHandshakeMetrics.class,
io.micrometer.core.instrument.binder.jetty.JettySslHandshakeMetrics.class,
JettySslHandshakeMetricsBinder.class })
@ConditionalOnProperty(name = "server.ssl.enabled", havingValue = "true") @ConditionalOnProperty(name = "server.ssl.enabled", havingValue = "true")
public JettySslHandshakeMetricsBinder jettySslHandshakeMetricsBinder(MeterRegistry meterRegistry) { public JettySslHandshakeMetricsBinder jettySslHandshakeMetricsBinder(MeterRegistry meterRegistry) {
return new JettySslHandshakeMetricsBinder(meterRegistry); return new JettySslHandshakeMetricsBinder(meterRegistry);

@ -16,8 +16,8 @@
package org.springframework.boot.actuate.autoconfigure.metrics.web.tomcat; package org.springframework.boot.actuate.autoconfigure.metrics.web.tomcat;
import io.micrometer.binder.tomcat.TomcatMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.tomcat.TomcatMetrics;
import org.apache.catalina.Manager; import org.apache.catalina.Manager;
import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration;
@ -43,7 +43,8 @@ public class TomcatMetricsAutoConfiguration {
@Bean @Bean
@ConditionalOnBean(MeterRegistry.class) @ConditionalOnBean(MeterRegistry.class)
@ConditionalOnMissingBean({ TomcatMetrics.class, TomcatMetricsBinder.class }) @ConditionalOnMissingBean({ TomcatMetrics.class, io.micrometer.core.instrument.binder.tomcat.TomcatMetrics.class,
TomcatMetricsBinder.class })
public TomcatMetricsBinder tomcatMetricsBinder(MeterRegistry meterRegistry) { public TomcatMetricsBinder tomcatMetricsBinder(MeterRegistry meterRegistry) {
return new TomcatMetricsBinder(meterRegistry); return new TomcatMetricsBinder(meterRegistry);
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,8 @@
package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation; package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
import io.micrometer.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.Statistic; import io.micrometer.core.instrument.Statistic;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry; import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,8 @@
package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation; package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
import io.micrometer.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.Clock; import io.micrometer.core.instrument.Clock;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.prometheus.PrometheusMeterRegistry; import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.prometheus.client.CollectorRegistry; import io.prometheus.client.CollectorRegistry;
import io.prometheus.client.exporter.common.TextFormat; import io.prometheus.client.exporter.common.TextFormat;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,11 +16,15 @@
package org.springframework.boot.actuate.autoconfigure.metrics; package org.springframework.boot.actuate.autoconfigure.metrics;
import io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics; import java.util.Arrays;
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics; import java.util.HashSet;
import io.micrometer.core.instrument.binder.jvm.JvmHeapPressureMetrics; import java.util.Set;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics; import io.micrometer.binder.jvm.ClassLoaderMetrics;
import io.micrometer.binder.jvm.JvmGcMetrics;
import io.micrometer.binder.jvm.JvmHeapPressureMetrics;
import io.micrometer.binder.jvm.JvmMemoryMetrics;
import io.micrometer.binder.jvm.JvmThreadMetrics;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun; import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
@ -55,34 +59,98 @@ class JvmMetricsAutoConfigurationTests {
.run(assertMetricsBeans().andThen((context) -> assertThat(context).hasBean("customJvmGcMetrics"))); .run(assertMetricsBeans().andThen((context) -> assertThat(context).hasBean("customJvmGcMetrics")));
} }
@Test
@Deprecated
void allowsCustomJvmGcMetricsToBeUsedBackwardsCompatible() {
this.contextRunner.withUserConfiguration(CustomJvmGcMetricsBackwardsCompatibleConfiguration.class)
.run(assertMetricsBeans(JvmGcMetrics.class).andThen((context) -> {
assertThat(context).hasBean("customJvmGcMetrics");
assertThat(context).doesNotHaveBean(JvmGcMetrics.class);
assertThat(context).hasSingleBean(io.micrometer.core.instrument.binder.jvm.JvmGcMetrics.class);
}));
}
@Test @Test
void allowsCustomJvmHeapPressureMetricsToBeUsed() { void allowsCustomJvmHeapPressureMetricsToBeUsed() {
this.contextRunner.withUserConfiguration(CustomJvmHeapPressureMetricsConfiguration.class).run( this.contextRunner.withUserConfiguration(CustomJvmHeapPressureMetricsConfiguration.class).run(
assertMetricsBeans().andThen((context) -> assertThat(context).hasBean("customJvmHeapPressureMetrics"))); assertMetricsBeans().andThen((context) -> assertThat(context).hasBean("customJvmHeapPressureMetrics")));
} }
@Test
@Deprecated
void allowsCustomJvmHeapPressureMetricsToBeUsedBackwardsCompatible() {
this.contextRunner.withUserConfiguration(CustomJvmHeapPressureMetricsBackwardsCompatibleConfiguration.class)
.run(assertMetricsBeans(JvmHeapPressureMetrics.class).andThen((context) -> {
assertThat(context).hasBean("customJvmHeapPressureMetrics");
assertThat(context).doesNotHaveBean(JvmHeapPressureMetrics.class);
assertThat(context)
.hasSingleBean(io.micrometer.core.instrument.binder.jvm.JvmHeapPressureMetrics.class);
}));
}
@Test @Test
void allowsCustomJvmMemoryMetricsToBeUsed() { void allowsCustomJvmMemoryMetricsToBeUsed() {
this.contextRunner.withUserConfiguration(CustomJvmMemoryMetricsConfiguration.class) this.contextRunner.withUserConfiguration(CustomJvmMemoryMetricsConfiguration.class)
.run(assertMetricsBeans().andThen((context) -> assertThat(context).hasBean("customJvmMemoryMetrics"))); .run(assertMetricsBeans().andThen((context) -> assertThat(context).hasBean("customJvmMemoryMetrics")));
} }
@Test
@Deprecated
void allowsCustomJvmMemoryMetricsToBeUsedBackwardsCompatible() {
this.contextRunner.withUserConfiguration(CustomJvmMemoryMetricsBackwardsCompatibleConfiguration.class)
.run(assertMetricsBeans(JvmMemoryMetrics.class).andThen((context) -> {
assertThat(context).hasBean("customJvmMemoryMetrics");
assertThat(context).doesNotHaveBean(JvmMemoryMetrics.class);
assertThat(context).hasSingleBean(io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics.class);
}));
}
@Test @Test
void allowsCustomJvmThreadMetricsToBeUsed() { void allowsCustomJvmThreadMetricsToBeUsed() {
this.contextRunner.withUserConfiguration(CustomJvmThreadMetricsConfiguration.class) this.contextRunner.withUserConfiguration(CustomJvmThreadMetricsConfiguration.class)
.run(assertMetricsBeans().andThen((context) -> assertThat(context).hasBean("customJvmThreadMetrics"))); .run(assertMetricsBeans().andThen((context) -> assertThat(context).hasBean("customJvmThreadMetrics")));
} }
@Test
@Deprecated
void allowsCustomJvmThreadMetricsToBeUsedBackwardsCompatible() {
this.contextRunner.withUserConfiguration(CustomJvmThreadMetricsBackwardsCompatibleConfiguration.class)
.run(assertMetricsBeans(JvmThreadMetrics.class).andThen((context) -> {
assertThat(context).hasBean("customJvmThreadMetrics");
assertThat(context).doesNotHaveBean(JvmThreadMetrics.class);
assertThat(context).hasSingleBean(io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics.class);
}));
}
@Test @Test
void allowsCustomClassLoaderMetricsToBeUsed() { void allowsCustomClassLoaderMetricsToBeUsed() {
this.contextRunner.withUserConfiguration(CustomClassLoaderMetricsConfiguration.class).run( this.contextRunner.withUserConfiguration(CustomClassLoaderMetricsConfiguration.class).run(
assertMetricsBeans().andThen((context) -> assertThat(context).hasBean("customClassLoaderMetrics"))); assertMetricsBeans().andThen((context) -> assertThat(context).hasBean("customClassLoaderMetrics")));
} }
private ContextConsumer<AssertableApplicationContext> assertMetricsBeans() { @Test
return (context) -> assertThat(context).hasSingleBean(JvmGcMetrics.class) @Deprecated
.hasSingleBean(JvmHeapPressureMetrics.class).hasSingleBean(JvmMemoryMetrics.class) void allowsCustomClassLoaderMetricsToBeUsedBackwardsCompatible() {
.hasSingleBean(JvmThreadMetrics.class).hasSingleBean(ClassLoaderMetrics.class); this.contextRunner.withUserConfiguration(CustomClassLoaderMetricsBackwardsCompatibleConfiguration.class)
.run(assertMetricsBeans(ClassLoaderMetrics.class).andThen((context) -> {
assertThat(context).hasBean("customClassLoaderMetrics");
assertThat(context).doesNotHaveBean(ClassLoaderMetrics.class);
assertThat(context)
.hasSingleBean(io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics.class);
}));
}
private ContextConsumer<AssertableApplicationContext> assertMetricsBeans(Class<?>... excludes) {
Set<Class<?>> beans = new HashSet<>(Arrays.asList(JvmGcMetrics.class, JvmHeapPressureMetrics.class,
JvmMemoryMetrics.class, JvmThreadMetrics.class, ClassLoaderMetrics.class));
for (Class<?> exclude : excludes) {
beans.remove(exclude);
}
return (context) -> {
for (Class<?> bean : beans) {
assertThat(context).hasSingleBean(bean);
}
};
} }
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ -95,6 +163,16 @@ class JvmMetricsAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomJvmGcMetricsBackwardsCompatibleConfiguration {
@Bean
io.micrometer.core.instrument.binder.jvm.JvmGcMetrics customJvmGcMetrics() {
return new io.micrometer.core.instrument.binder.jvm.JvmGcMetrics();
}
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class CustomJvmHeapPressureMetricsConfiguration { static class CustomJvmHeapPressureMetricsConfiguration {
@ -105,6 +183,16 @@ class JvmMetricsAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomJvmHeapPressureMetricsBackwardsCompatibleConfiguration {
@Bean
io.micrometer.core.instrument.binder.jvm.JvmHeapPressureMetrics customJvmHeapPressureMetrics() {
return new io.micrometer.core.instrument.binder.jvm.JvmHeapPressureMetrics();
}
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class CustomJvmMemoryMetricsConfiguration { static class CustomJvmMemoryMetricsConfiguration {
@ -115,6 +203,16 @@ class JvmMetricsAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomJvmMemoryMetricsBackwardsCompatibleConfiguration {
@Bean
io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics customJvmMemoryMetrics() {
return new io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics();
}
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class CustomJvmThreadMetricsConfiguration { static class CustomJvmThreadMetricsConfiguration {
@ -125,6 +223,16 @@ class JvmMetricsAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomJvmThreadMetricsBackwardsCompatibleConfiguration {
@Bean
io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics customJvmThreadMetrics() {
return new io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics();
}
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class CustomClassLoaderMetricsConfiguration { static class CustomClassLoaderMetricsConfiguration {
@ -135,4 +243,14 @@ class JvmMetricsAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomClassLoaderMetricsBackwardsCompatibleConfiguration {
@Bean
io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics customClassLoaderMetrics() {
return new io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics();
}
}
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.metrics; package org.springframework.boot.actuate.autoconfigure.metrics;
import io.micrometer.core.instrument.binder.logging.Log4j2Metrics; import io.micrometer.binder.logging.Log4j2Metrics;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -55,6 +55,17 @@ class Log4J2MetricsWithLog4jLoggerContextAutoConfigurationTests {
(context) -> assertThat(context).hasSingleBean(Log4j2Metrics.class).hasBean("customLog4J2Metrics")); (context) -> assertThat(context).hasSingleBean(Log4j2Metrics.class).hasBean("customLog4J2Metrics"));
} }
@Test
@Deprecated
void allowsCustomLog4J2MetricsToBeUsedBackwardsCompatible() {
assertThat(LogManager.getContext().getClass().getName())
.isEqualTo("org.apache.logging.log4j.core.LoggerContext");
this.contextRunner.withUserConfiguration(CustomLog4J2MetricsConfigurationBackwardsCompatible.class)
.run((context) -> assertThat(context)
.hasSingleBean(io.micrometer.core.instrument.binder.logging.Log4j2Metrics.class)
.doesNotHaveBean(Log4j2Metrics.class).hasBean("customLog4J2Metrics"));
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class CustomLog4J2MetricsConfiguration { static class CustomLog4J2MetricsConfiguration {
@ -65,4 +76,14 @@ class Log4J2MetricsWithLog4jLoggerContextAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomLog4J2MetricsConfigurationBackwardsCompatible {
@Bean
io.micrometer.core.instrument.binder.logging.Log4j2Metrics customLog4J2Metrics() {
return new io.micrometer.core.instrument.binder.logging.Log4j2Metrics();
}
}
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.metrics; package org.springframework.boot.actuate.autoconfigure.metrics;
import io.micrometer.core.instrument.binder.logging.Log4j2Metrics; import io.micrometer.binder.logging.Log4j2Metrics;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.slf4j.SLF4JLoggerContext; import org.apache.logging.slf4j.SLF4JLoggerContext;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.metrics; package org.springframework.boot.actuate.autoconfigure.metrics;
import io.micrometer.core.instrument.binder.logging.LogbackMetrics; import io.micrometer.binder.logging.LogbackMetrics;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun; import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
@ -49,6 +49,15 @@ class LogbackMetricsAutoConfigurationTests {
(context) -> assertThat(context).hasSingleBean(LogbackMetrics.class).hasBean("customLogbackMetrics")); (context) -> assertThat(context).hasSingleBean(LogbackMetrics.class).hasBean("customLogbackMetrics"));
} }
@Test
@Deprecated
void allowsCustomLogbackMetricsToBeUsedBackwardsCompatible() {
this.contextRunner.withUserConfiguration(CustomLogbackMetricsConfigurationBackwardsCompatible.class)
.run((context) -> assertThat(context)
.hasSingleBean(io.micrometer.core.instrument.binder.logging.LogbackMetrics.class)
.doesNotHaveBean(LogbackMetrics.class).hasBean("customLogbackMetrics"));
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class CustomLogbackMetricsConfiguration { static class CustomLogbackMetricsConfiguration {
@ -59,4 +68,14 @@ class LogbackMetricsAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomLogbackMetricsConfigurationBackwardsCompatible {
@Bean
io.micrometer.core.instrument.binder.logging.LogbackMetrics customLogbackMetrics() {
return new io.micrometer.core.instrument.binder.logging.LogbackMetrics();
}
}
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.metrics; package org.springframework.boot.actuate.autoconfigure.metrics;
import io.micrometer.core.instrument.binder.logging.LogbackMetrics; import io.micrometer.binder.logging.LogbackMetrics;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,10 +20,10 @@ import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import io.micrometer.binder.system.FileDescriptorMetrics;
import io.micrometer.binder.system.ProcessorMetrics;
import io.micrometer.binder.system.UptimeMetrics;
import io.micrometer.core.instrument.Tags; import io.micrometer.core.instrument.Tags;
import io.micrometer.core.instrument.binder.system.FileDescriptorMetrics;
import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
import io.micrometer.core.instrument.binder.system.UptimeMetrics;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun; import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
@ -58,6 +58,15 @@ class SystemMetricsAutoConfigurationTests {
(context) -> assertThat(context).hasSingleBean(UptimeMetrics.class).hasBean("customUptimeMetrics")); (context) -> assertThat(context).hasSingleBean(UptimeMetrics.class).hasBean("customUptimeMetrics"));
} }
@Test
@Deprecated
void allowsCustomUptimeMetricsToBeUsedBackwardsCompatible() {
this.contextRunner.withUserConfiguration(CustomUptimeMetricsConfigurationBackwardsCompatible.class)
.run((context) -> assertThat(context)
.hasSingleBean(io.micrometer.core.instrument.binder.system.UptimeMetrics.class)
.doesNotHaveBean(UptimeMetrics.class).hasBean("customUptimeMetrics"));
}
@Test @Test
void autoConfiguresProcessorMetrics() { void autoConfiguresProcessorMetrics() {
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(ProcessorMetrics.class)); this.contextRunner.run((context) -> assertThat(context).hasSingleBean(ProcessorMetrics.class));
@ -70,6 +79,15 @@ class SystemMetricsAutoConfigurationTests {
.hasBean("customProcessorMetrics")); .hasBean("customProcessorMetrics"));
} }
@Test
@Deprecated
void allowsCustomProcessorMetricsToBeUsedBackwardsCompatible() {
this.contextRunner.withUserConfiguration(CustomProcessorMetricsConfigurationBackwardsCompatible.class)
.run((context) -> assertThat(context)
.hasSingleBean(io.micrometer.core.instrument.binder.system.ProcessorMetrics.class)
.doesNotHaveBean(ProcessorMetrics.class).hasBean("customProcessorMetrics"));
}
@Test @Test
void autoConfiguresFileDescriptorMetrics() { void autoConfiguresFileDescriptorMetrics() {
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(FileDescriptorMetrics.class)); this.contextRunner.run((context) -> assertThat(context).hasSingleBean(FileDescriptorMetrics.class));
@ -82,6 +100,15 @@ class SystemMetricsAutoConfigurationTests {
.hasBean("customFileDescriptorMetrics")); .hasBean("customFileDescriptorMetrics"));
} }
@Test
@Deprecated
void allowsCustomFileDescriptorMetricsToBeUsedBackwardsCompatible() {
this.contextRunner.withUserConfiguration(CustomFileDescriptorMetricsConfigurationBackwardsCompatible.class)
.run((context) -> assertThat(context)
.hasSingleBean(io.micrometer.core.instrument.binder.system.FileDescriptorMetrics.class)
.doesNotHaveBean(FileDescriptorMetrics.class).hasBean("customFileDescriptorMetrics"));
}
@Test @Test
void autoConfiguresDiskSpaceMetrics() { void autoConfiguresDiskSpaceMetrics() {
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(DiskSpaceMetricsBinder.class)); this.contextRunner.run((context) -> assertThat(context).hasSingleBean(DiskSpaceMetricsBinder.class));
@ -125,6 +152,16 @@ class SystemMetricsAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomUptimeMetricsConfigurationBackwardsCompatible {
@Bean
io.micrometer.core.instrument.binder.system.UptimeMetrics customUptimeMetrics() {
return new io.micrometer.core.instrument.binder.system.UptimeMetrics();
}
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class CustomProcessorMetricsConfiguration { static class CustomProcessorMetricsConfiguration {
@ -135,6 +172,16 @@ class SystemMetricsAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomProcessorMetricsConfigurationBackwardsCompatible {
@Bean
io.micrometer.core.instrument.binder.system.ProcessorMetrics customProcessorMetrics() {
return new io.micrometer.core.instrument.binder.system.ProcessorMetrics();
}
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class CustomFileDescriptorMetricsConfiguration { static class CustomFileDescriptorMetricsConfiguration {
@ -145,6 +192,16 @@ class SystemMetricsAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomFileDescriptorMetricsConfigurationBackwardsCompatible {
@Bean
io.micrometer.core.instrument.binder.system.FileDescriptorMetrics customFileDescriptorMetrics() {
return new io.micrometer.core.instrument.binder.system.FileDescriptorMetrics();
}
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class CustomDiskSpaceMetricsConfiguration { static class CustomDiskSpaceMetricsConfiguration {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,8 @@
package org.springframework.boot.actuate.autoconfigure.metrics.export.humio; package org.springframework.boot.actuate.autoconfigure.metrics.export.humio;
import io.micrometer.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.Clock; import io.micrometer.core.instrument.Clock;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.humio.HumioConfig; import io.micrometer.humio.HumioConfig;
import io.micrometer.humio.HumioMeterRegistry; import io.micrometer.humio.HumioMeterRegistry;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,12 +22,12 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import io.micrometer.binder.jersey.server.DefaultJerseyTagsProvider;
import io.micrometer.binder.jersey.server.JerseyTagsProvider;
import io.micrometer.binder.jersey.server.MetricsApplicationEventListener;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.Timer; import io.micrometer.core.instrument.Timer;
import io.micrometer.core.instrument.binder.jersey.server.DefaultJerseyTagsProvider;
import io.micrometer.core.instrument.binder.jersey.server.JerseyTagsProvider;
import io.micrometer.core.instrument.binder.jersey.server.MetricsApplicationEventListener;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.monitoring.RequestEvent; import org.glassfish.jersey.server.monitoring.RequestEvent;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -85,6 +85,17 @@ class JerseyServerMetricsAutoConfigurationTests {
.run((context) -> assertThat(context).hasSingleBean(CustomJerseyTagsProvider.class)); .run((context) -> assertThat(context).hasSingleBean(CustomJerseyTagsProvider.class));
} }
@Test
@Deprecated
void shouldHonorExistingTagProviderBackwardsCompatible() {
this.webContextRunner.withUserConfiguration(CustomJerseyTagsProviderBackwardsCompatibleConfiguration.class)
.run((context) -> {
assertThat(context)
.hasSingleBean(io.micrometer.core.instrument.binder.jersey.server.JerseyTagsProvider.class);
assertThat(context).doesNotHaveBean(JerseyTagsProvider.class);
});
}
@Test @Test
void httpRequestsAreTimed() { void httpRequestsAreTimed() {
this.webContextRunner.run((context) -> { this.webContextRunner.run((context) -> {
@ -144,6 +155,16 @@ class JerseyServerMetricsAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomJerseyTagsProviderBackwardsCompatibleConfiguration {
@Bean
io.micrometer.core.instrument.binder.jersey.server.JerseyTagsProvider customJerseyTagsProvider() {
return new CustomJerseyTagsProviderBackwardsCompatible();
}
}
static class CustomJerseyTagsProvider implements JerseyTagsProvider { static class CustomJerseyTagsProvider implements JerseyTagsProvider {
@Override @Override
@ -158,4 +179,19 @@ class JerseyServerMetricsAutoConfigurationTests {
} }
static class CustomJerseyTagsProviderBackwardsCompatible
implements io.micrometer.core.instrument.binder.jersey.server.JerseyTagsProvider {
@Override
public Iterable<Tag> httpRequestTags(RequestEvent event) {
return null;
}
@Override
public Iterable<Tag> httpLongRequestTags(RequestEvent event) {
return null;
}
}
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,12 +23,12 @@ import com.mongodb.client.MongoClient;
import com.mongodb.client.internal.MongoClientImpl; import com.mongodb.client.internal.MongoClientImpl;
import com.mongodb.connection.ConnectionPoolSettings; import com.mongodb.connection.ConnectionPoolSettings;
import com.mongodb.event.ConnectionPoolListener; import com.mongodb.event.ConnectionPoolListener;
import io.micrometer.core.instrument.binder.mongodb.DefaultMongoCommandTagsProvider; import io.micrometer.binder.mongodb.DefaultMongoCommandTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.DefaultMongoConnectionPoolTagsProvider; import io.micrometer.binder.mongodb.DefaultMongoConnectionPoolTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider; import io.micrometer.binder.mongodb.MongoCommandTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider; import io.micrometer.binder.mongodb.MongoConnectionPoolTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsCommandListener; import io.micrometer.binder.mongodb.MongoMetricsCommandListener;
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsConnectionPoolListener; import io.micrometer.binder.mongodb.MongoMetricsConnectionPoolListener;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun; import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
@ -93,7 +93,7 @@ class MongoMetricsAutoConfigurationTests {
@Test @Test
void whenThereIsACustomMetricsCommandTagsProviderItIsUsed() { void whenThereIsACustomMetricsCommandTagsProviderItIsUsed() {
final MongoCommandTagsProvider customTagsProvider = mock(MongoCommandTagsProvider.class); MongoCommandTagsProvider customTagsProvider = mock(MongoCommandTagsProvider.class);
this.contextRunner.with(MetricsRun.simple()) this.contextRunner.with(MetricsRun.simple())
.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class)) .withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
.withBean("customMongoCommandTagsProvider", MongoCommandTagsProvider.class, () -> customTagsProvider) .withBean("customMongoCommandTagsProvider", MongoCommandTagsProvider.class, () -> customTagsProvider)
@ -101,9 +101,27 @@ class MongoMetricsAutoConfigurationTests {
.isSameAs(customTagsProvider)); .isSameAs(customTagsProvider));
} }
@Test
@Deprecated
void whenThereIsACustomMetricsCommandTagsProviderItIsUsedBackwardsCompatible() {
io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider customTagsProvider = mock(
io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider.class);
this.contextRunner.with(MetricsRun.simple())
.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
.withBean("customMongoCommandTagsProvider",
io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider.class,
() -> customTagsProvider)
.run((context) -> {
assertThat(context).hasBean("customMongoCommandTagsProvider");
assertThat(context)
.hasSingleBean(io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider.class);
assertThat(context).doesNotHaveBean(MongoCommandTagsProvider.class);
});
}
@Test @Test
void whenThereIsACustomMetricsConnectionPoolTagsProviderItIsUsed() { void whenThereIsACustomMetricsConnectionPoolTagsProviderItIsUsed() {
final MongoConnectionPoolTagsProvider customTagsProvider = mock(MongoConnectionPoolTagsProvider.class); MongoConnectionPoolTagsProvider customTagsProvider = mock(MongoConnectionPoolTagsProvider.class);
this.contextRunner.with(MetricsRun.simple()) this.contextRunner.with(MetricsRun.simple())
.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class)) .withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
.withBean("customMongoConnectionPoolTagsProvider", MongoConnectionPoolTagsProvider.class, .withBean("customMongoConnectionPoolTagsProvider", MongoConnectionPoolTagsProvider.class,
@ -112,6 +130,25 @@ class MongoMetricsAutoConfigurationTests {
.isSameAs(customTagsProvider)); .isSameAs(customTagsProvider));
} }
@Test
@Deprecated
void whenThereIsACustomMetricsConnectionPoolTagsProviderItIsUsedBackwardsCompatible() {
io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider customTagsProvider = mock(
io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider.class);
this.contextRunner.with(MetricsRun.simple())
.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
.withBean("customMongoConnectionPoolTagsProvider",
io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider.class,
() -> customTagsProvider)
.run((context) -> {
assertThat(context).hasBean("customMongoConnectionPoolTagsProvider");
assertThat(context).hasSingleBean(
io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider.class);
assertThat(context).doesNotHaveBean(MongoConnectionPoolTagsProvider.class);
});
}
@Test @Test
void whenThereIsNoMongoClientSettingsOnClasspathThenNoMetricsCommandListenerIsAdded() { void whenThereIsNoMongoClientSettingsOnClasspathThenNoMetricsCommandListenerIsAdded() {
this.contextRunner.with(MetricsRun.simple()) this.contextRunner.with(MetricsRun.simple())
@ -176,26 +213,25 @@ class MongoMetricsAutoConfigurationTests {
} }
private MongoClientSettings getActualMongoClientSettingsUsedToConstructClient( private MongoClientSettings getActualMongoClientSettingsUsedToConstructClient(
final AssertableApplicationContext context) { AssertableApplicationContext context) {
final MongoClientImpl mongoClient = (MongoClientImpl) context.getBean(MongoClient.class); MongoClientImpl mongoClient = (MongoClientImpl) context.getBean(MongoClient.class);
return mongoClient.getSettings(); return mongoClient.getSettings();
} }
private List<ConnectionPoolListener> getConnectionPoolListenersFromClient( private List<ConnectionPoolListener> getConnectionPoolListenersFromClient(AssertableApplicationContext context) {
final AssertableApplicationContext context) {
MongoClientSettings mongoClientSettings = getActualMongoClientSettingsUsedToConstructClient(context); MongoClientSettings mongoClientSettings = getActualMongoClientSettingsUsedToConstructClient(context);
ConnectionPoolSettings connectionPoolSettings = mongoClientSettings.getConnectionPoolSettings(); ConnectionPoolSettings connectionPoolSettings = mongoClientSettings.getConnectionPoolSettings();
return connectionPoolSettings.getConnectionPoolListeners(); return connectionPoolSettings.getConnectionPoolListeners();
} }
private MongoCommandTagsProvider getMongoCommandTagsProviderUsedToConstructListener( private MongoCommandTagsProvider getMongoCommandTagsProviderUsedToConstructListener(
final AssertableApplicationContext context) { AssertableApplicationContext context) {
MongoMetricsCommandListener listener = context.getBean(MongoMetricsCommandListener.class); MongoMetricsCommandListener listener = context.getBean(MongoMetricsCommandListener.class);
return (MongoCommandTagsProvider) ReflectionTestUtils.getField(listener, "tagsProvider"); return (MongoCommandTagsProvider) ReflectionTestUtils.getField(listener, "tagsProvider");
} }
private MongoConnectionPoolTagsProvider getMongoConnectionPoolTagsProviderUsedToConstructListener( private MongoConnectionPoolTagsProvider getMongoConnectionPoolTagsProviderUsedToConstructListener(
final AssertableApplicationContext context) { AssertableApplicationContext context) {
MongoMetricsConnectionPoolListener listener = context.getBean(MongoMetricsConnectionPoolListener.class); MongoMetricsConnectionPoolListener listener = context.getBean(MongoMetricsConnectionPoolListener.class);
return (MongoConnectionPoolTagsProvider) ReflectionTestUtils.getField(listener, "tagsProvider"); return (MongoConnectionPoolTagsProvider) ReflectionTestUtils.getField(listener, "tagsProvider");
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,11 +24,11 @@ import java.util.concurrent.CyclicBarrier;
import javax.servlet.DispatcherType; import javax.servlet.DispatcherType;
import io.micrometer.binder.jvm.JvmMemoryMetrics;
import io.micrometer.binder.logging.LogbackMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.MockClock; import io.micrometer.core.instrument.MockClock;
import io.micrometer.core.instrument.binder.MeterBinder; import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.binder.logging.LogbackMetrics;
import io.micrometer.core.instrument.simple.SimpleConfig; import io.micrometer.core.instrument.simple.SimpleConfig;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry; import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,9 +16,13 @@
package org.springframework.boot.actuate.autoconfigure.metrics.web.jetty; package org.springframework.boot.actuate.autoconfigure.metrics.web.jetty;
import io.micrometer.binder.jetty.JettyConnectionMetrics;
import io.micrometer.binder.jetty.JettyServerThreadPoolMetrics;
import io.micrometer.binder.jetty.JettySslHandshakeMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tags; import io.micrometer.core.instrument.Tags;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry; import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import org.eclipse.jetty.util.thread.ThreadPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
@ -86,6 +90,28 @@ class JettyMetricsAutoConfigurationTests {
.hasBean("customJettyServerThreadPoolMetricsBinder")); .hasBean("customJettyServerThreadPoolMetricsBinder"));
} }
@Test
void allowsCustomJettyServerThreadPoolMetrics() {
new WebApplicationContextRunner().withConfiguration(AutoConfigurations.of(JettyMetricsAutoConfiguration.class))
.withUserConfiguration(CustomJettyServerThreadPoolMetrics.class, MeterRegistryConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(JettyServerThreadPoolMetrics.class)
.doesNotHaveBean(JettyServerThreadPoolMetricsBinder.class)
.hasBean("customJettyServerThreadPoolMetrics"));
}
@Test
@Deprecated
void allowsCustomJettyServerThreadPoolMetricsBackwardsCompatible() {
new WebApplicationContextRunner().withConfiguration(AutoConfigurations.of(JettyMetricsAutoConfiguration.class))
.withUserConfiguration(CustomJettyServerThreadPoolMetricsBackwardsCompatible.class,
MeterRegistryConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(io.micrometer.core.instrument.binder.jetty.JettyServerThreadPoolMetrics.class)
.doesNotHaveBean(JettyServerThreadPoolMetrics.class)
.doesNotHaveBean(JettyServerThreadPoolMetricsBinder.class)
.hasBean("customJettyServerThreadPoolMetrics"));
}
@Test @Test
void autoConfiguresConnectionMetricsWithEmbeddedServletJetty() { void autoConfiguresConnectionMetricsWithEmbeddedServletJetty() {
new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new) new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new)
@ -130,6 +156,26 @@ class JettyMetricsAutoConfigurationTests {
}); });
} }
@Test
void allowsCustomJettyConnectionMetrics() {
new WebApplicationContextRunner().withConfiguration(AutoConfigurations.of(JettyMetricsAutoConfiguration.class))
.withUserConfiguration(CustomJettyConnectionMetrics.class, MeterRegistryConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(JettyConnectionMetrics.class)
.doesNotHaveBean(JettyConnectionMetricsBinder.class).hasBean("customJettyConnectionMetrics"));
}
@Test
@Deprecated
void allowsCustomJettyConnectionMetricsBackwardsCompatible() {
new WebApplicationContextRunner().withConfiguration(AutoConfigurations.of(JettyMetricsAutoConfiguration.class))
.withUserConfiguration(CustomJettyConnectionMetricsBackwardsCompatible.class,
MeterRegistryConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(io.micrometer.core.instrument.binder.jetty.JettyConnectionMetrics.class)
.doesNotHaveBean(JettyConnectionMetrics.class)
.doesNotHaveBean(JettyConnectionMetricsBinder.class).hasBean("customJettyConnectionMetrics"));
}
@Test @Test
void autoConfiguresSslHandshakeMetricsWithEmbeddedServletJetty() { void autoConfiguresSslHandshakeMetricsWithEmbeddedServletJetty() {
new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new) new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new)
@ -187,6 +233,28 @@ class JettyMetricsAutoConfigurationTests {
.hasBean("customJettySslHandshakeMetricsBinder")); .hasBean("customJettySslHandshakeMetricsBinder"));
} }
@Test
void allowsCustomJettySslHandshakeMetrics() {
new WebApplicationContextRunner().withConfiguration(AutoConfigurations.of(JettyMetricsAutoConfiguration.class))
.withUserConfiguration(CustomJettySslHandshakeMetrics.class, MeterRegistryConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(JettySslHandshakeMetrics.class)
.doesNotHaveBean(JettySslHandshakeMetricsBinder.class)
.hasBean("customJettySslHandshakeMetrics"));
}
@Test
@Deprecated
void allowsCustomJettySslHandshakeMetricsBackwardsCompatible() {
new WebApplicationContextRunner().withConfiguration(AutoConfigurations.of(JettyMetricsAutoConfiguration.class))
.withUserConfiguration(CustomJettySslHandshakeMetricsBackwardsCompatible.class,
MeterRegistryConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(io.micrometer.core.instrument.binder.jetty.JettySslHandshakeMetrics.class)
.doesNotHaveBean(JettySslHandshakeMetrics.class)
.doesNotHaveBean(JettySslHandshakeMetricsBinder.class)
.hasBean("customJettySslHandshakeMetrics"));
}
@Test @Test
void doesNotAutoConfigureSslHandshakeMetricsWhenSslEnabledPropertyNotSpecified() { void doesNotAutoConfigureSslHandshakeMetricsWhenSslEnabledPropertyNotSpecified() {
new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new) new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new)
@ -255,6 +323,27 @@ class JettyMetricsAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomJettyServerThreadPoolMetrics {
@Bean
JettyServerThreadPoolMetrics customJettyServerThreadPoolMetrics() {
return new JettyServerThreadPoolMetrics(mock(ThreadPool.class), Tags.empty());
}
}
@Configuration(proxyBeanMethods = false)
static class CustomJettyServerThreadPoolMetricsBackwardsCompatible {
@Bean
io.micrometer.core.instrument.binder.jetty.JettyServerThreadPoolMetrics customJettyServerThreadPoolMetrics() {
return new io.micrometer.core.instrument.binder.jetty.JettyServerThreadPoolMetrics(mock(ThreadPool.class),
Tags.empty());
}
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class CustomJettyConnectionMetricsBinder { static class CustomJettyConnectionMetricsBinder {
@ -265,6 +354,27 @@ class JettyMetricsAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomJettyConnectionMetrics {
@Bean
JettyConnectionMetrics customJettyConnectionMetrics(MeterRegistry meterRegistry) {
return new JettyConnectionMetrics(meterRegistry);
}
}
@Configuration(proxyBeanMethods = false)
static class CustomJettyConnectionMetricsBackwardsCompatible {
@Bean
io.micrometer.core.instrument.binder.jetty.JettyConnectionMetrics customJettyConnectionMetrics(
MeterRegistry meterRegistry) {
return new io.micrometer.core.instrument.binder.jetty.JettyConnectionMetrics(meterRegistry);
}
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class CustomJettySslHandshakeMetricsBinder { static class CustomJettySslHandshakeMetricsBinder {
@ -275,4 +385,25 @@ class JettyMetricsAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomJettySslHandshakeMetrics {
@Bean
JettySslHandshakeMetrics customJettySslHandshakeMetrics(MeterRegistry meterRegistry) {
return new JettySslHandshakeMetrics(meterRegistry);
}
}
@Configuration(proxyBeanMethods = false)
static class CustomJettySslHandshakeMetricsBackwardsCompatible {
@Bean
io.micrometer.core.instrument.binder.jetty.JettySslHandshakeMetrics customJettySslHandshakeMetrics(
MeterRegistry meterRegistry) {
return new io.micrometer.core.instrument.binder.jetty.JettySslHandshakeMetrics(meterRegistry);
}
}
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,8 +19,8 @@ package org.springframework.boot.actuate.autoconfigure.metrics.web.tomcat;
import java.util.Collections; import java.util.Collections;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import io.micrometer.binder.tomcat.TomcatMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.tomcat.TomcatMetrics;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry; import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import org.apache.tomcat.util.modeler.Registry; import org.apache.tomcat.util.modeler.Registry;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -108,6 +108,16 @@ class TomcatMetricsAutoConfigurationTests {
.hasBean("customTomcatMetrics")); .hasBean("customTomcatMetrics"));
} }
@Test
@Deprecated
void allowsCustomTomcatMetricsToBeUsedBackwardsCompatible() {
new WebApplicationContextRunner().withConfiguration(AutoConfigurations.of(TomcatMetricsAutoConfiguration.class))
.withUserConfiguration(MeterRegistryConfiguration.class, CustomTomcatMetricsBackwardsCompatible.class)
.run((context) -> assertThat(context).doesNotHaveBean(TomcatMetricsBinder.class)
.hasSingleBean(io.micrometer.core.instrument.binder.tomcat.TomcatMetrics.class)
.doesNotHaveBean(TomcatMetrics.class).hasBean("customTomcatMetrics"));
}
private ApplicationStartedEvent createApplicationStartedEvent(ConfigurableApplicationContext context) { private ApplicationStartedEvent createApplicationStartedEvent(ConfigurableApplicationContext context) {
return new ApplicationStartedEvent(new SpringApplication(), null, context, null); return new ApplicationStartedEvent(new SpringApplication(), null, context, null);
} }
@ -164,6 +174,16 @@ class TomcatMetricsAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class CustomTomcatMetricsBackwardsCompatible {
@Bean
io.micrometer.core.instrument.binder.tomcat.TomcatMetrics customTomcatMetrics() {
return new io.micrometer.core.instrument.binder.tomcat.TomcatMetrics(null, Collections.emptyList());
}
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class CustomTomcatMetricsBinder { static class CustomTomcatMetricsBinder {

@ -23,6 +23,7 @@ dependencies {
optional("com.zaxxer:HikariCP") optional("com.zaxxer:HikariCP")
optional("io.lettuce:lettuce-core") optional("io.lettuce:lettuce-core")
optional("io.micrometer:micrometer-core") optional("io.micrometer:micrometer-core")
optional("io.micrometer:micrometer-binders")
optional("io.micrometer:micrometer-registry-prometheus") optional("io.micrometer:micrometer-registry-prometheus")
optional("io.prometheus:simpleclient_pushgateway") { optional("io.prometheus:simpleclient_pushgateway") {
exclude(group: "javax.xml.bind", module: "jaxb-api") exclude(group: "javax.xml.bind", module: "jaxb-api")

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,9 +16,9 @@
package org.springframework.boot.actuate.metrics.cache; package org.springframework.boot.actuate.metrics.cache;
import io.micrometer.binder.cache.CaffeineCacheMetrics;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.MeterBinder; import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.cache.CaffeineCacheMetrics;
import org.springframework.cache.caffeine.CaffeineCache; import org.springframework.cache.caffeine.CaffeineCache;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,9 +16,9 @@
package org.springframework.boot.actuate.metrics.cache; package org.springframework.boot.actuate.metrics.cache;
import io.micrometer.binder.cache.EhCache2Metrics;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.MeterBinder; import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.cache.EhCache2Metrics;
import org.springframework.cache.ehcache.EhCacheCache; import org.springframework.cache.ehcache.EhCacheCache;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,9 +19,9 @@ package org.springframework.boot.actuate.metrics.cache;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import com.hazelcast.spring.cache.HazelcastCache; import com.hazelcast.spring.cache.HazelcastCache;
import io.micrometer.binder.cache.HazelcastCacheMetrics;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.MeterBinder; import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.cache.HazelcastCacheMetrics;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,9 +16,9 @@
package org.springframework.boot.actuate.metrics.cache; package org.springframework.boot.actuate.metrics.cache;
import io.micrometer.binder.cache.JCacheMetrics;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.MeterBinder; import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.cache.JCacheMetrics;
import org.springframework.cache.jcache.JCacheCache; import org.springframework.cache.jcache.JCacheCache;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,11 +18,11 @@ package org.springframework.boot.actuate.metrics.cache;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import io.micrometer.binder.cache.CacheMeterBinder;
import io.micrometer.core.instrument.FunctionCounter; import io.micrometer.core.instrument.FunctionCounter;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.TimeGauge; import io.micrometer.core.instrument.TimeGauge;
import io.micrometer.core.instrument.binder.cache.CacheMeterBinder;
import org.springframework.data.redis.cache.RedisCache; import org.springframework.data.redis.cache.RedisCache;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,10 +19,10 @@ package org.springframework.boot.actuate.metrics.system;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import io.micrometer.binder.system.DiskSpaceMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.MeterBinder; import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.system.DiskSpaceMetrics;
import org.springframework.util.Assert; import org.springframework.util.Assert;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,9 +18,9 @@ package org.springframework.boot.actuate.metrics.web.jetty;
import java.util.Collections; import java.util.Collections;
import io.micrometer.binder.jetty.JettyConnectionMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.jetty.JettyConnectionMetrics;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
/** /**

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,9 +18,9 @@ package org.springframework.boot.actuate.metrics.web.jetty;
import java.util.Collections; import java.util.Collections;
import io.micrometer.binder.jetty.JettyServerThreadPoolMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.jetty.JettyServerThreadPoolMetrics;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.thread.ThreadPool; import org.eclipse.jetty.util.thread.ThreadPool;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,9 +18,9 @@ package org.springframework.boot.actuate.metrics.web.jetty;
import java.util.Collections; import java.util.Collections;
import io.micrometer.binder.jetty.JettySslHandshakeMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.jetty.JettySslHandshakeMetrics;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
/** /**

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,9 +18,9 @@ package org.springframework.boot.actuate.metrics.web.tomcat;
import java.util.Collections; import java.util.Collections;
import io.micrometer.binder.tomcat.TomcatMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.tomcat.TomcatMetrics;
import org.apache.catalina.Container; import org.apache.catalina.Container;
import org.apache.catalina.Context; import org.apache.catalina.Context;
import org.apache.catalina.Manager; import org.apache.catalina.Manager;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,9 +21,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import io.micrometer.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.MockClock; import io.micrometer.core.instrument.MockClock;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.simple.SimpleConfig; import io.micrometer.core.instrument.simple.SimpleConfig;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry; import io.micrometer.core.instrument.simple.SimpleMeterRegistry;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,8 +19,8 @@ package org.springframework.boot.actuate.metrics.cache;
import java.util.Collections; import java.util.Collections;
import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.Caffeine;
import io.micrometer.binder.cache.CaffeineCacheMetrics;
import io.micrometer.core.instrument.binder.MeterBinder; import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.cache.CaffeineCacheMetrics;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.cache.caffeine.CaffeineCache; import org.springframework.cache.caffeine.CaffeineCache;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,8 +18,8 @@ package org.springframework.boot.actuate.metrics.cache;
import java.util.Collections; import java.util.Collections;
import io.micrometer.binder.cache.EhCache2Metrics;
import io.micrometer.core.instrument.binder.MeterBinder; import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.cache.EhCache2Metrics;
import net.sf.ehcache.Cache; import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager; import net.sf.ehcache.CacheManager;
import net.sf.ehcache.config.CacheConfiguration; import net.sf.ehcache.config.CacheConfiguration;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,8 +20,8 @@ import java.util.Collections;
import com.hazelcast.map.IMap; import com.hazelcast.map.IMap;
import com.hazelcast.spring.cache.HazelcastCache; import com.hazelcast.spring.cache.HazelcastCache;
import io.micrometer.binder.cache.HazelcastCacheMetrics;
import io.micrometer.core.instrument.binder.MeterBinder; import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.cache.HazelcastCacheMetrics;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,8 +20,8 @@ import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.Collections; import java.util.Collections;
import io.micrometer.binder.cache.JCacheMetrics;
import io.micrometer.core.instrument.binder.MeterBinder; import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.cache.JCacheMetrics;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock; import org.mockito.Mock;

@ -1242,7 +1242,7 @@ bom {
] ]
} }
} }
library("Micrometer", "1.9.0-M3") { library("Micrometer", "1.9.0-SNAPSHOT") {
group("io.micrometer") { group("io.micrometer") {
modules = [ modules = [
"micrometer-registry-stackdriver" { "micrometer-registry-stackdriver" {

@ -77,6 +77,7 @@ dependencies {
implementation("ch.qos.logback:logback-classic") implementation("ch.qos.logback:logback-classic")
implementation("com.zaxxer:HikariCP") implementation("com.zaxxer:HikariCP")
implementation("io.micrometer:micrometer-core") implementation("io.micrometer:micrometer-core")
implementation("io.micrometer:micrometer-binders")
implementation("io.micrometer:micrometer-registry-graphite") implementation("io.micrometer:micrometer-registry-graphite")
implementation("io.micrometer:micrometer-registry-jmx") implementation("io.micrometer:micrometer-registry-jmx")
implementation("io.projectreactor.netty:reactor-netty-http") implementation("io.projectreactor.netty:reactor-netty-http")

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,8 +17,8 @@
package org.springframework.boot.docs.actuator.metrics.supported.mongodb.command; package org.springframework.boot.docs.actuator.metrics.supported.mongodb.command;
import com.mongodb.event.CommandEvent; import com.mongodb.event.CommandEvent;
import io.micrometer.binder.mongodb.MongoCommandTagsProvider;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider;
class CustomCommandTagsProvider implements MongoCommandTagsProvider { class CustomCommandTagsProvider implements MongoCommandTagsProvider {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,7 @@
package org.springframework.boot.docs.actuator.metrics.supported.mongodb.command; package org.springframework.boot.docs.actuator.metrics.supported.mongodb.command;
import io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider; import io.micrometer.binder.mongodb.MongoCommandTagsProvider;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,8 +17,8 @@
package org.springframework.boot.docs.actuator.metrics.supported.mongodb.connectionpool; package org.springframework.boot.docs.actuator.metrics.supported.mongodb.connectionpool;
import com.mongodb.event.ConnectionPoolCreatedEvent; import com.mongodb.event.ConnectionPoolCreatedEvent;
import io.micrometer.binder.mongodb.MongoConnectionPoolTagsProvider;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider;
public class CustomConnectionPoolTagsProvider implements MongoConnectionPoolTagsProvider { public class CustomConnectionPoolTagsProvider implements MongoConnectionPoolTagsProvider {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,7 @@
package org.springframework.boot.docs.actuator.metrics.supported.mongodb.connectionpool; package org.springframework.boot.docs.actuator.metrics.supported.mongodb.connectionpool;
import io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider; import io.micrometer.binder.mongodb.MongoConnectionPoolTagsProvider;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;

@ -17,8 +17,8 @@
package org.springframework.boot.docs.actuator.metrics.supported.mongodb.command package org.springframework.boot.docs.actuator.metrics.supported.mongodb.command
import com.mongodb.event.CommandEvent import com.mongodb.event.CommandEvent
import io.micrometer.binder.mongodb.MongoCommandTagsProvider
import io.micrometer.core.instrument.Tag import io.micrometer.core.instrument.Tag
import io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider
class CustomCommandTagsProvider : MongoCommandTagsProvider { class CustomCommandTagsProvider : MongoCommandTagsProvider {

@ -16,7 +16,7 @@
package org.springframework.boot.docs.actuator.metrics.supported.mongodb.command package org.springframework.boot.docs.actuator.metrics.supported.mongodb.command
import io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider import io.micrometer.binder.mongodb.MongoCommandTagsProvider
import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Configuration

@ -17,8 +17,8 @@
package org.springframework.boot.docs.actuator.metrics.supported.mongodb.connectionpool package org.springframework.boot.docs.actuator.metrics.supported.mongodb.connectionpool
import com.mongodb.event.ConnectionPoolCreatedEvent import com.mongodb.event.ConnectionPoolCreatedEvent
import io.micrometer.binder.mongodb.MongoConnectionPoolTagsProvider
import io.micrometer.core.instrument.Tag import io.micrometer.core.instrument.Tag
import io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider
class CustomConnectionPoolTagsProvider : MongoConnectionPoolTagsProvider { class CustomConnectionPoolTagsProvider : MongoConnectionPoolTagsProvider {

@ -16,7 +16,7 @@
package org.springframework.boot.docs.actuator.metrics.supported.mongodb.connectionpool package org.springframework.boot.docs.actuator.metrics.supported.mongodb.connectionpool
import io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider import io.micrometer.binder.mongodb.MongoConnectionPoolTagsProvider
import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Configuration

@ -8,4 +8,5 @@ dependencies {
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter")) api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter"))
api(project(":spring-boot-project:spring-boot-actuator-autoconfigure")) api(project(":spring-boot-project:spring-boot-actuator-autoconfigure"))
api("io.micrometer:micrometer-core") api("io.micrometer:micrometer-core")
api("io.micrometer:micrometer-binders")
} }

Loading…
Cancel
Save