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:
Dave Syer
2015-05-31 12:51:07 +01:00
parent 80ff92919c
commit 8a83bd12bd
9 changed files with 112 additions and 49 deletions

View File

@@ -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);