Search in sources :

Example 31 with SimpleMeterRegistry

use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project micrometer by micrometer-metrics.

the class DatabaseTableMetricsTest method setup.

@BeforeEach
void setup() throws SQLException {
    registry = new SimpleMeterRegistry();
    ds = new JDBCDataSource();
    ds.setURL("jdbc:hsqldb:mem:test");
    try (Connection conn = ds.getConnection()) {
        conn.prepareStatement("CREATE TABLE foo (id int)").execute();
        conn.prepareStatement("INSERT INTO foo VALUES (1)").executeUpdate();
    }
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Connection(java.sql.Connection) JDBCDataSource(org.hsqldb.jdbc.JDBCDataSource) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 32 with SimpleMeterRegistry

use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project micrometer by micrometer-metrics.

the class ClassLoaderMetricsTest method classLoadingMetrics.

@Test
void classLoadingMetrics() {
    MeterRegistry registry = new SimpleMeterRegistry();
    new ClassLoaderMetrics().bindTo(registry);
    assertThat(registry.get("jvm.classes.loaded").gauge().value()).isGreaterThan(0);
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 33 with SimpleMeterRegistry

use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project micrometer by micrometer-metrics.

the class UptimeMetricsTest method uptimeMetricsMock.

@Test
void uptimeMetricsMock() {
    MeterRegistry registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock());
    RuntimeMXBean runtimeMXBean = mock(RuntimeMXBean.class);
    when(runtimeMXBean.getUptime()).thenReturn(1337L);
    when(runtimeMXBean.getStartTime()).thenReturn(4711L);
    new UptimeMetrics(runtimeMXBean, emptyList()).bindTo(registry);
    assertThat(registry.get("process.uptime").timeGauge().value()).isEqualTo(1.337);
    assertThat(registry.get("process.start.time").timeGauge().value()).isEqualTo(4.711);
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) RuntimeMXBean(java.lang.management.RuntimeMXBean) MockClock(io.micrometer.core.instrument.MockClock) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 34 with SimpleMeterRegistry

use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project micrometer by micrometer-metrics.

the class UptimeMetricsTest method uptimeMetricsRuntime.

@Test
void uptimeMetricsRuntime() {
    MeterRegistry registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock());
    new UptimeMetrics().bindTo(registry);
    registry.get("process.uptime").timeGauge();
    registry.get("process.start.time").timeGauge();
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MockClock(io.micrometer.core.instrument.MockClock) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 35 with SimpleMeterRegistry

use of io.micrometer.core.instrument.simple.SimpleMeterRegistry in project micrometer by micrometer-metrics.

the class MetricsRequestEventListenerTimedTest method configure.

@Override
protected Application configure() {
    registry = new SimpleMeterRegistry();
    longTaskRequestStartedLatch = new CountDownLatch(1);
    longTaskRequestReleaseLatch = new CountDownLatch(1);
    final MetricsApplicationEventListener listener = new MetricsApplicationEventListener(registry, new DefaultJerseyTagsProvider(), METRIC_NAME, false);
    final ResourceConfig config = new ResourceConfig();
    config.register(listener);
    config.register(new TimedResource(longTaskRequestStartedLatch, longTaskRequestReleaseLatch));
    config.register(TimedOnClassResource.class);
    return config;
}
Also used : TimedResource(io.micrometer.jersey2.server.resources.TimedResource) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)42 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)20 Test (org.junit.jupiter.api.Test)20 Test (org.junit.Test)18 Match (io.vertx.micrometer.Match)8 Timer (io.micrometer.core.instrument.Timer)6 LongTaskTimer (io.micrometer.core.instrument.LongTaskTimer)5 MockClock (io.micrometer.core.instrument.MockClock)5 Counter (io.micrometer.core.instrument.Counter)4 DistributionSummary (io.micrometer.core.instrument.DistributionSummary)4 Gauge (io.micrometer.core.instrument.Gauge)4 HystrixPropertiesCommandDefault (com.netflix.hystrix.strategy.properties.HystrixPropertiesCommandDefault)2 Issue (io.micrometer.core.Issue)2 Tag (io.micrometer.core.instrument.Tag)2 MeterFilter (io.micrometer.core.instrument.config.MeterFilter)2 CountAtBucket (io.micrometer.core.instrument.distribution.CountAtBucket)2 SimpleConfig (io.micrometer.core.instrument.simple.SimpleConfig)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 LongAdder (java.util.concurrent.atomic.LongAdder)2 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)2