use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class TaskExecutorMetricsAutoConfigurationTests method taskSchedulerInstrumentationCanBeDisabled.
@Test
void taskSchedulerInstrumentationCanBeDisabled() {
this.contextRunner.withPropertyValues("management.metrics.enable.executor=false").withConfiguration(AutoConfigurations.of(TaskSchedulingAutoConfiguration.class)).withUserConfiguration(SchedulingTestConfiguration.class).run((context) -> {
MeterRegistry registry = context.getBean(MeterRegistry.class);
assertThat(registry.find("executor.completed").tags("name", "taskScheduler").functionCounter()).isNull();
});
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class TaskExecutorMetricsAutoConfigurationTests method taskSchedulerUsingAutoConfigurationIsInstrumented.
@Test
void taskSchedulerUsingAutoConfigurationIsInstrumented() {
this.contextRunner.withConfiguration(AutoConfigurations.of(TaskSchedulingAutoConfiguration.class)).withUserConfiguration(SchedulingTestConfiguration.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("taskScheduler"));
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 threadPoolTaskExecutorWithNoTaskExecutorIsIgnored.
@Test
void threadPoolTaskExecutorWithNoTaskExecutorIsIgnored() {
ThreadPoolTaskExecutor unavailableTaskExecutor = mock(ThreadPoolTaskExecutor.class);
given(unavailableTaskExecutor.getThreadPoolExecutor()).willThrow(new IllegalStateException("Test"));
this.contextRunner.withBean("firstTaskExecutor", ThreadPoolTaskExecutor.class, ThreadPoolTaskExecutor::new).withBean("customName", ThreadPoolTaskExecutor.class, () -> unavailableTaskExecutor).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("firstTaskExecutor"));
});
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class TaskExecutorMetricsAutoConfigurationTests method taskSchedulersWithCustomNamesAreInstrumented.
@Test
void taskSchedulersWithCustomNamesAreInstrumented() {
this.contextRunner.withBean("firstTaskScheduler", Executor.class, ThreadPoolTaskScheduler::new).withBean("customName", ThreadPoolTaskScheduler.class, ThreadPoolTaskScheduler::new).run((context) -> {
MeterRegistry registry = context.getBean(MeterRegistry.class);
Collection<FunctionCounter> meters = registry.get("executor.completed").functionCounters();
assertThat(meters).map((meter) -> meter.getId().getTag("name")).containsExactlyInAnyOrder("firstTaskScheduler", "customName");
});
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class DataSourcePoolMetricsAutoConfigurationTests method autoConfiguredHikariDataSourceIsInstrumented.
@Test
void autoConfiguredHikariDataSourceIsInstrumented() {
this.contextRunner.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)).run((context) -> {
context.getBean(DataSource.class).getConnection();
MeterRegistry registry = context.getBean(MeterRegistry.class);
registry.get("hikaricp.connections").meter();
});
}
Aggregations