use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class ConnectionPoolMetricsAutoConfigurationTests method allConnectionPoolsCanBeInstrumented.
@Test
void allConnectionPoolsCanBeInstrumented() {
this.contextRunner.withUserConfiguration(TwoConnectionPoolsConfiguration.class).run((context) -> {
MeterRegistry registry = context.getBean(MeterRegistry.class);
assertThat(registry.find("r2dbc.pool.acquired").gauges()).extracting(Meter::getId).extracting((id) -> id.getTag("name")).containsExactlyInAnyOrder("firstPool", "secondPool");
});
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class WebClientMetricsConfigurationTests method getInitializedMeterRegistry.
private MeterRegistry getInitializedMeterRegistry(AssertableApplicationContext context) {
WebClient webClient = mockWebClient(context.getBean(WebClient.Builder.class));
MeterRegistry registry = context.getBean(MeterRegistry.class);
for (int i = 0; i < 3; i++) {
webClient.get().uri("https://example.org/projects/" + i).retrieve().toBodilessEntity().block(Duration.ofSeconds(30));
}
return registry;
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class WebClientMetricsConfigurationTests method autoTimeRequestsCanBeConfigured.
@Test
void autoTimeRequestsCanBeConfigured() {
this.contextRunner.withPropertyValues("management.metrics.web.client.request.autotime.enabled=true", "management.metrics.web.client.request.autotime.percentiles=0.5,0.7", "management.metrics.web.client.request.autotime.percentiles-histogram=true").run((context) -> {
MeterRegistry registry = getInitializedMeterRegistry(context);
Timer timer = registry.get("http.client.requests").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);
});
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class TaskExecutorMetricsAutoConfigurationTests method taskExecutorUsingAutoConfigurationIsInstrumented.
@Test
void taskExecutorUsingAutoConfigurationIsInstrumented() {
this.contextRunner.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)).run((context) -> {
MeterRegistry registry = context.getBean(MeterRegistry.class);
Collection<FunctionCounter> meters = registry.get("executor.completed").functionCounters();
assertThat(meters).singleElement().satisfies((meter) -> assertThat(meter.getId().getTag("name")).isEqualTo("applicationTaskExecutor"));
assertThatExceptionOfType(MeterNotFoundException.class).isThrownBy(() -> registry.get("executor").timer());
});
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class TaskExecutorMetricsAutoConfigurationTests method taskExecutorInstrumentationCanBeDisabled.
@Test
void taskExecutorInstrumentationCanBeDisabled() {
this.contextRunner.withPropertyValues("management.metrics.enable.executor=false").withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class)).run((context) -> {
MeterRegistry registry = context.getBean(MeterRegistry.class);
assertThat(registry.find("executor.completed").tags("name", "applicationTaskExecutor").functionCounter()).isNull();
});
}
Aggregations