use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class DataSourcePoolMetricsAutoConfigurationTests method autoConfiguredHikariDataSourceIsInstrumentedWhenUsingDeprecatedDataSourceInitialization.
@Test
@Deprecated
void autoConfiguredHikariDataSourceIsInstrumentedWhenUsingDeprecatedDataSourceInitialization() {
this.contextRunner.withPropertyValues("spring.datasource.schema:db/create-custom-schema.sql").withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)).run((context) -> {
context.getBean(DataSource.class).getConnection();
MeterRegistry registry = context.getBean(MeterRegistry.class);
registry.get("hikaricp.connections").meter();
});
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class CacheMetricsAutoConfigurationTests method cacheInstrumentationCanBeDisabled.
@Test
void cacheInstrumentationCanBeDisabled() {
this.contextRunner.withPropertyValues("management.metrics.enable.cache=false", "spring.cache.type=caffeine", "spring.cache.cache-names=cache1").run((context) -> {
MeterRegistry registry = context.getBean(MeterRegistry.class);
assertThat(registry.find("cache.requests").tags("name", "cache1").tags("cacheManager", "cacheManager").meter()).isNull();
});
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class CacheMetricsAutoConfigurationTests method autoConfiguredNonSupportedCacheManagerIsIgnored.
@Test
void autoConfiguredNonSupportedCacheManagerIsIgnored() {
this.contextRunner.withPropertyValues("spring.cache.type=simple", "spring.cache.cache-names=cache1,cache2").run((context) -> {
MeterRegistry registry = context.getBean(MeterRegistry.class);
assertThat(registry.find("cache.gets").tags("name", "cache1").tags("cacheManager", "cacheManager").meter()).isNull();
assertThat(registry.find("cache.gets").tags("name", "cache2").tags("cacheManager", "cacheManager").meter()).isNull();
});
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class MetricsAutoConfigurationIntegrationTests method emptyCompositeIsCreatedWhenNoMeterRegistriesAreAutoConfigured.
@Test
void emptyCompositeIsCreatedWhenNoMeterRegistriesAreAutoConfigured() {
new ApplicationContextRunner().with(MetricsRun.limitedTo()).run((context) -> {
MeterRegistry registry = context.getBean(MeterRegistry.class);
assertThat(registry).isInstanceOf(CompositeMeterRegistry.class);
assertThat(((CompositeMeterRegistry) registry).getRegistries()).isEmpty();
});
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class MetricsAutoConfigurationIntegrationTests method propertyBasedCommonTagsIsAutoConfigured.
@Test
void propertyBasedCommonTagsIsAutoConfigured() {
this.contextRunner.withPropertyValues("management.metrics.tags.region=test", "management.metrics.tags.origin=local").run((context) -> {
MeterRegistry registry = context.getBean(MeterRegistry.class);
registry.counter("my.counter", "env", "qa");
assertThat(registry.find("my.counter").tags("env", "qa").tags("region", "test").tags("origin", "local").counter()).isNotNull();
});
}
Aggregations