Refactor annotations for metric export
Users can add @ExportMetric[Reader,Writer] to readers and writers that they want to participate in the default exporter. There is also still an @ActuatorMetricWriter that is used for the legacy (non-Java8) Gauge and CounterServices.
This commit is contained in:
@@ -19,6 +19,7 @@ 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.autoconfigure.ExportMetricWriter;
|
||||
import org.springframework.boot.actuate.metrics.export.MetricExportProperties;
|
||||
import org.springframework.boot.actuate.metrics.jmx.JmxMetricWriter;
|
||||
import org.springframework.boot.actuate.metrics.repository.redis.RedisMetricRepository;
|
||||
@@ -38,6 +39,7 @@ public class SampleRedisExportApplication {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ExportMetricWriter
|
||||
public RedisMetricRepository redisMetricWriter(
|
||||
RedisConnectionFactory connectionFactory) {
|
||||
return new RedisMetricRepository(connectionFactory, this.export.getRedis().getPrefix(),
|
||||
@@ -45,6 +47,7 @@ public class SampleRedisExportApplication {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ExportMetricWriter
|
||||
public JmxMetricWriter jmxMetricWriter(
|
||||
@Qualifier("mbeanExporter") MBeanExporter exporter) {
|
||||
return new JmxMetricWriter(exporter);
|
||||
|
||||
Reference in New Issue
Block a user