use of org.springframework.boot.actuate.metrics.rich.RichGauge in project spring-boot by spring-projects.
the class PublicMetricsAutoConfigurationTests method richGaugePublicMetrics.
@Test
public void richGaugePublicMetrics() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(RichGaugeReaderConfig.class, MetricRepositoryAutoConfiguration.class, PublicMetricsAutoConfiguration.class);
RichGaugeReader richGaugeReader = context.getBean(RichGaugeReader.class);
assertThat(richGaugeReader).isNotNull();
given(richGaugeReader.findAll()).willReturn(Collections.singletonList(new RichGauge("bar", 3.7d)));
RichGaugeReaderPublicMetrics publicMetrics = context.getBean(RichGaugeReaderPublicMetrics.class);
assertThat(publicMetrics).isNotNull();
Collection<Metric<?>> metrics = publicMetrics.metrics();
assertThat(metrics).isNotNull();
assertThat(6).isEqualTo(metrics.size());
assertHasMetric(metrics, new Metric<>("bar.val", 3.7d));
assertHasMetric(metrics, new Metric<>("bar.avg", 3.7d));
assertHasMetric(metrics, new Metric<>("bar.min", 3.7d));
assertHasMetric(metrics, new Metric<>("bar.max", 3.7d));
assertHasMetric(metrics, new Metric<>("bar.alpha", -1.d));
assertHasMetric(metrics, new Metric<>("bar.count", 1L));
context.close();
}
use of org.springframework.boot.actuate.metrics.rich.RichGauge in project spring-boot by spring-projects.
the class RichGaugeExporter method next.
@Override
protected Iterable<Metric<?>> next(String group) {
RichGauge rich = this.reader.findOne(group);
Collection<Metric<?>> metrics = new ArrayList<>();
metrics.add(new Metric<Number>(group + MIN, rich.getMin()));
metrics.add(new Metric<Number>(group + MAX, rich.getMax()));
metrics.add(new Metric<Number>(group + COUNT, rich.getCount()));
metrics.add(new Metric<Number>(group + VALUE, rich.getValue()));
metrics.add(new Metric<Number>(group + AVG, rich.getAverage()));
metrics.add(new Metric<Number>(group + ALPHA, rich.getAlpha()));
return metrics;
}
Aggregations