use of io.micrometer.core.instrument.distribution.HistogramSnapshot in project spring-boot by spring-projects.
the class WebMvcMetricsFilterAutoTimedTests method metricsCanBeAutoTimed.
@Test
void metricsCanBeAutoTimed() throws Exception {
this.mvc.perform(get("/api/10")).andExpect(status().isOk());
Timer timer = this.registry.get("http.server.requests").tags("status", "200").timer();
assertThat(timer.count()).isEqualTo(1L);
HistogramSnapshot snapshot = timer.takeSnapshot();
assertThat(snapshot.percentileValues()).hasSize(2);
assertThat(snapshot.percentileValues()[0].percentile()).isEqualTo(0.5);
assertThat(snapshot.percentileValues()[1].percentile()).isEqualTo(0.95);
}
use of io.micrometer.core.instrument.distribution.HistogramSnapshot in project spring-boot by spring-projects.
the class RepositoryMetricsAutoConfigurationTests method autoTimeRequestsCanBeConfigured.
@Test
void autoTimeRequestsCanBeConfigured() {
this.contextRunner.withPropertyValues("management.metrics.data.repository.autotime.enabled=true", "management.metrics.data.repository.autotime.percentiles=0.5,0.7").run((context) -> {
MeterRegistry registry = getInitializedMeterRegistry(context, ExampleRepository.class);
Timer timer = registry.get("spring.data.repository.invocations").timer();
HistogramSnapshot snapshot = timer.takeSnapshot();
assertThat(snapshot.percentileValues()).hasSize(2);
assertThat(snapshot.percentileValues()[0].percentile()).isEqualTo(0.5);
assertThat(snapshot.percentileValues()[1].percentile()).isEqualTo(0.7);
});
}
Aggregations