Search in sources :

Example 31 with MeterRegistry

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);
}
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 32 with MeterRegistry

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();
}
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 33 with MeterRegistry

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);
}
Also used : ClassLoaderMetrics(io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics) JvmThreadMetrics(io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics) ProcessorMetrics(io.micrometer.core.instrument.binder.system.ProcessorMetrics) JvmMemoryMetrics(io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) JvmGcMetrics(io.micrometer.core.instrument.binder.jvm.JvmGcMetrics)

Example 34 with MeterRegistry

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
        });
    });
}
Also used : Timer(io.micrometer.core.instrument.Timer) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry)

Example 35 with MeterRegistry

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"));
}
Also used : MeterRegistry(io.micrometer.core.instrument.MeterRegistry) PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry)

Aggregations

MeterRegistry (io.micrometer.core.instrument.MeterRegistry)42 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)21 Test (org.junit.jupiter.api.Test)12 Test (org.junit.Test)10 Timer (io.micrometer.core.instrument.Timer)9 Duration (java.time.Duration)9 SampleConfig (io.micrometer.core.samples.utils.SampleConfig)8 Match (io.vertx.micrometer.Match)8 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 Flux (reactor.core.publisher.Flux)6 Counter (io.micrometer.core.instrument.Counter)5 MetricUtils.getName (io.github.resilience4j.micrometer.MetricUtils.getName)4 MeterBinder (io.micrometer.core.instrument.binder.MeterBinder)4 PrometheusMeterRegistry (io.micrometer.prometheus.PrometheusMeterRegistry)4 Objects.requireNonNull (java.util.Objects.requireNonNull)4 TimeUnit (java.util.concurrent.TimeUnit)4