Search in sources :

Example 76 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 77 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 78 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)

Example 79 with MeterRegistry

use of io.micrometer.core.instrument.MeterRegistry in project vertx-micrometer-metrics by vert-x3.

the class GaugesTest method shouldIgnoreGaugeLabel.

@Test
public void shouldIgnoreGaugeLabel() {
    MeterRegistry registry = new SimpleMeterRegistry();
    BackendRegistries.registerMatchers(registry, Collections.singletonList(new Match().setLabel("address").setType(MatchType.REGEX).setValue(".*").setAlias("_")));
    Gauges<LongAdder> gauges = new Gauges<>("my_gauge", "", LongAdder::new, LongAdder::doubleValue, registry, Label.ADDRESS);
    gauges.get("addr1").increment();
    gauges.get("addr1").increment();
    gauges.get("addr2").increment();
    Gauge g = registry.find("my_gauge").tags("address", "_").gauge();
    assertThat(g.value()).isEqualTo(3d);
    g = registry.find("my_gauge").tags("address", "addr1").gauge();
    assertThat(g).isNull();
    g = registry.find("my_gauge").tags("address", "addr2").gauge();
    assertThat(g).isNull();
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Match(io.vertx.micrometer.Match) Gauge(io.micrometer.core.instrument.Gauge) Test(org.junit.Test)

Example 80 with MeterRegistry

use of io.micrometer.core.instrument.MeterRegistry in project vertx-micrometer-metrics by vert-x3.

the class SummariesTest method shouldIgnoreSummaryLabel.

@Test
public void shouldIgnoreSummaryLabel() {
    MeterRegistry registry = new SimpleMeterRegistry();
    BackendRegistries.registerMatchers(registry, Collections.singletonList(new Match().setLabel("address").setType(MatchType.REGEX).setValue(".*").setAlias("_")));
    Summaries summaries = new Summaries("my_summary", "", registry, Label.ADDRESS);
    summaries.get("addr1").record(5);
    summaries.get("addr1").record(8);
    summaries.get("addr2").record(10);
    DistributionSummary s = registry.find("my_summary").tags("address", "_").summary();
    assertThat(s.count()).isEqualTo(3);
    assertThat(s.totalAmount()).isEqualTo(23);
    s = registry.find("my_summary").tags("address", "addr1").summary();
    assertThat(s).isNull();
    s = registry.find("my_summary").tags("address", "addr2").summary();
    assertThat(s).isNull();
}
Also used : DistributionSummary(io.micrometer.core.instrument.DistributionSummary) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Match(io.vertx.micrometer.Match) Test(org.junit.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