Search in sources :

Example 46 with MeterRegistry

use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.

the class RabbitMetricsAutoConfigurationTests method autoConfiguredConnectionFactoryIsInstrumented.

@Test
void autoConfiguredConnectionFactoryIsInstrumented() {
    this.contextRunner.run((context) -> {
        MeterRegistry registry = context.getBean(MeterRegistry.class);
        registry.get("rabbitmq.connections").meter();
    });
}
Also used : MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 47 with MeterRegistry

use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.

the class DataSourcePoolMetricsAutoConfigurationTests method hikariProxiedDataSourceCanBeInstrumented.

@Test
void hikariProxiedDataSourceCanBeInstrumented() {
    this.contextRunner.withUserConfiguration(ProxiedHikariDataSourcesConfiguration.class).withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)).run((context) -> {
        context.getBean("proxiedDataSource", DataSource.class).getConnection();
        context.getBean("delegateDataSource", DataSource.class).getConnection();
        MeterRegistry registry = context.getBean(MeterRegistry.class);
        registry.get("hikaricp.connections").tags("pool", "firstDataSource").meter();
        registry.get("hikaricp.connections").tags("pool", "secondOne").meter();
    });
}
Also used : DelegatingDataSource(org.springframework.jdbc.datasource.DelegatingDataSource) HikariDataSource(com.zaxxer.hikari.HikariDataSource) DataSource(javax.sql.DataSource) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 48 with MeterRegistry

use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.

the class DataSourcePoolMetricsAutoConfigurationTests method dataSourceInstrumentationCanBeDisabled.

@Test
void dataSourceInstrumentationCanBeDisabled() {
    this.contextRunner.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)).withPropertyValues("management.metrics.enable.jdbc=false").run((context) -> {
        context.getBean(DataSource.class).getConnection().getMetaData();
        MeterRegistry registry = context.getBean(MeterRegistry.class);
        assertThat(registry.find("jdbc.connections.max").tags("name", "dataSource").meter()).isNull();
    });
}
Also used : DataSourceAutoConfiguration(org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 49 with MeterRegistry

use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.

the class DataSourcePoolMetricsAutoConfigurationTests method hikariDataSourceInstrumentationCanBeDisabled.

@Test
void hikariDataSourceInstrumentationCanBeDisabled() {
    this.contextRunner.withPropertyValues("management.metrics.enable.hikaricp=false").withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)).run((context) -> {
        context.getBean(DataSource.class).getConnection();
        MeterRegistry registry = context.getBean(MeterRegistry.class);
        assertThat(registry.find("hikaricp.connections").meter()).isNull();
    });
}
Also used : DelegatingDataSource(org.springframework.jdbc.datasource.DelegatingDataSource) HikariDataSource(com.zaxxer.hikari.HikariDataSource) DataSource(javax.sql.DataSource) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 50 with MeterRegistry

use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.

the class DataSourcePoolMetricsAutoConfigurationTests method autoConfiguredDataSourceIsInstrumented.

@Test
void autoConfiguredDataSourceIsInstrumented() {
    this.contextRunner.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)).run((context) -> {
        context.getBean(DataSource.class).getConnection().getMetaData();
        MeterRegistry registry = context.getBean(MeterRegistry.class);
        registry.get("jdbc.connections.max").tags("name", "dataSource").meter();
    });
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Aggregations

MeterRegistry (io.micrometer.core.instrument.MeterRegistry)136 Test (org.junit.jupiter.api.Test)83 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)60 CompositeMeterRegistry (io.micrometer.core.instrument.composite.CompositeMeterRegistry)17 Timer (io.micrometer.core.instrument.Timer)15 Test (org.junit.Test)15 PrometheusMeterRegistry (io.micrometer.prometheus.PrometheusMeterRegistry)12 Duration (java.time.Duration)11 ApplicationContextRunner (org.springframework.boot.test.context.runner.ApplicationContextRunner)10 HikariDataSource (com.zaxxer.hikari.HikariDataSource)9 DataSource (javax.sql.DataSource)9 DelegatingDataSource (org.springframework.jdbc.datasource.DelegatingDataSource)9 SampleConfig (io.micrometer.core.samples.utils.SampleConfig)8 Match (io.vertx.micrometer.Match)8 FunctionCounter (io.micrometer.core.instrument.FunctionCounter)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 Normal (cern.jet.random.Normal)6 MersenneTwister64 (cern.jet.random.engine.MersenneTwister64)6 RandomEngine (cern.jet.random.engine.RandomEngine)6 Gauge (io.micrometer.core.instrument.Gauge)6