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();
}
}
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);
}
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);
}
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();
}
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;
}
Aggregations