use of org.springframework.boot.actuate.metrics.rich.InMemoryRichGaugeRepository in project spring-boot by spring-projects.
the class RichGaugeReaderPublicMetricsTests method testMetrics.
@Test
public void testMetrics() throws Exception {
InMemoryRichGaugeRepository repository = new InMemoryRichGaugeRepository();
repository.set(new Metric<>("a", 0.d, new Date()));
repository.set(new Metric<>("a", 0.5d, new Date()));
RichGaugeReaderPublicMetrics metrics = new RichGaugeReaderPublicMetrics(repository);
Map<String, Metric<?>> results = new HashMap<>();
for (Metric<?> metric : metrics.metrics()) {
results.put(metric.getName(), metric);
}
assertThat(results.containsKey("a.val")).isTrue();
assertThat(results.get("a.val").getValue().doubleValue()).isEqualTo(0.5d);
assertThat(results.containsKey("a.avg")).isTrue();
assertThat(results.get("a.avg").getValue().doubleValue()).isEqualTo(0.25d);
assertThat(results.containsKey("a.min")).isTrue();
assertThat(results.get("a.min").getValue().doubleValue()).isEqualTo(0.0d);
assertThat(results.containsKey("a.max")).isTrue();
assertThat(results.get("a.max").getValue().doubleValue()).isEqualTo(0.5d);
assertThat(results.containsKey("a.count")).isTrue();
assertThat(results.get("a.count").getValue().longValue()).isEqualTo(2L);
assertThat(results.containsKey("a.alpha")).isTrue();
assertThat(results.get("a.alpha").getValue().doubleValue()).isEqualTo(-1.d);
}
Aggregations