diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricsProperties.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/MetricExportProperties.java similarity index 100% rename from spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricsProperties.java rename to spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/MetricExportProperties.java diff --git a/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/ExportProperties.java b/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/ExportProperties.java index 769325d3f1..57c4685cb9 100644 --- a/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/ExportProperties.java +++ b/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/ExportProperties.java @@ -19,7 +19,7 @@ package sample.metrics.redis; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.util.StringUtils; -@ConfigurationProperties("metrics.export") +@ConfigurationProperties("redis.metrics.export") class ExportProperties { private String prefix = "spring.metrics"; diff --git a/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/SampleRedisExportApplication.java b/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/SampleRedisExportApplication.java index 28915ed659..e60e8e81f7 100644 --- a/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/SampleRedisExportApplication.java +++ b/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/SampleRedisExportApplication.java @@ -17,13 +17,15 @@ package sample.metrics.redis; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.SpringApplication; +import org.springframework.boot.actuate.metrics.jmx.JmxMetricWriter; import org.springframework.boot.actuate.metrics.repository.redis.RedisMetricRepository; -import org.springframework.boot.actuate.metrics.writer.MetricWriter; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.jmx.export.MBeanExporter; @SpringBootApplication @EnableConfigurationProperties(ExportProperties.class) @@ -37,9 +39,16 @@ public class SampleRedisExportApplication { } @Bean - public MetricWriter redisMetricWriter(RedisConnectionFactory connectionFactory) { + public RedisMetricRepository redisMetricWriter( + RedisConnectionFactory connectionFactory) { return new RedisMetricRepository(connectionFactory, this.export.getPrefix(), this.export.getKey()); } + @Bean + public JmxMetricWriter jmxMetricWriter( + @Qualifier("mbeanExporter") MBeanExporter exporter) { + return new JmxMetricWriter(exporter); + } + } diff --git a/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/resources/application.properties index 8f126a3c80..1e6fcf1d04 100644 --- a/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/resources/application.properties +++ b/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/resources/application.properties @@ -1,3 +1,3 @@ service.name: Phil -metrics.export.prefix: metrics.sample.${random.value:0000}.${spring.application.name:application} -metrics.export.key: keys.metrics.sample +redis.metrics.export.prefix: metrics.sample.${random.value:0000}.${spring.application.name:application} +redis.metrics.export.key: keys.metrics.sample