use of io.micrometer.core.instrument.MeterRegistry 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.MeterRegistry 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.MeterRegistry in project vertx-micrometer-metrics by vert-x3.
the class MetricsExamples method instrumentJVM.
public void instrumentJVM() {
MeterRegistry registry = BackendRegistries.getDefaultNow();
new ClassLoaderMetrics().bindTo(registry);
new JvmMemoryMetrics().bindTo(registry);
new JvmGcMetrics().bindTo(registry);
new ProcessorMetrics().bindTo(registry);
new JvmThreadMetrics().bindTo(registry);
}
use of io.micrometer.core.instrument.MeterRegistry in project vertx-micrometer-metrics by vert-x3.
the class MetricsExamples method customTimerExample.
public void customTimerExample() {
MeterRegistry registry = BackendRegistries.getDefaultNow();
Timer timer = Timer.builder("my.timer").description("a description of what this timer does").register(registry);
vertx.setPeriodic(1000, l -> {
timer.record(() -> {
// Running here some operation to monitor
});
});
}
use of io.micrometer.core.instrument.MeterRegistry in project vertx-micrometer-metrics by vert-x3.
the class MetricsExamples method useMicrometerFilters.
public void useMicrometerFilters() {
MeterRegistry registry = BackendRegistries.getDefaultNow();
registry.config().meterFilter(MeterFilter.ignoreTags("address", "remote")).meterFilter(MeterFilter.renameTag("vertx.verticle", "deployed", "instances"));
}
Aggregations