Search in sources :

Example 1 with SimpleMeterRegistry

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

the class CountersTest method shouldIgnoreCounterLabel.

@Test
public void shouldIgnoreCounterLabel() {
    MeterRegistry registry = new SimpleMeterRegistry();
    BackendRegistries.registerMatchers(registry, Collections.singletonList(new Match().setLabel("address").setType(MatchType.REGEX).setValue(".*").setAlias("_")));
    Counters counters = new Counters("my_counter", "", registry, Label.ADDRESS);
    counters.get("addr1").increment();
    counters.get("addr1").increment();
    counters.get("addr2").increment();
    Counter c = registry.find("my_counter").tags("address", "_").counter();
    assertThat(c.count()).isEqualTo(3d);
    c = registry.find("my_counter").tags("address", "addr1").counter();
    assertThat(c).isNull();
    c = registry.find("my_counter").tags("address", "addr2").counter();
    assertThat(c).isNull();
}
Also used : Counter(io.micrometer.core.instrument.Counter) 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)

Example 2 with SimpleMeterRegistry

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

the class CountersTest method shouldAliasCounterLabel.

@Test
public void shouldAliasCounterLabel() {
    MeterRegistry registry = new SimpleMeterRegistry();
    BackendRegistries.registerMatchers(registry, Collections.singletonList(new Match().setLabel("address").setType(MatchType.REGEX).setValue("addr1").setAlias("1")));
    Counters counters = new Counters("my_counter", "", registry, Label.ADDRESS);
    counters.get("addr1").increment();
    counters.get("addr1").increment();
    counters.get("addr2").increment();
    Counter c = registry.find("my_counter").tags("address", "1").counter();
    assertThat(c.count()).isEqualTo(2d);
    c = registry.find("my_counter").tags("address", "addr1").counter();
    assertThat(c).isNull();
    c = registry.find("my_counter").tags("address", "addr2").counter();
    assertThat(c.count()).isEqualTo(1d);
}
Also used : Counter(io.micrometer.core.instrument.Counter) 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)

Example 3 with SimpleMeterRegistry

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

the class GaugesTest method shouldAliasGaugeLabel.

@Test
public void shouldAliasGaugeLabel() {
    MeterRegistry registry = new SimpleMeterRegistry();
    BackendRegistries.registerMatchers(registry, Collections.singletonList(new Match().setLabel("address").setType(MatchType.REGEX).setValue("addr1").setAlias("1")));
    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", "1").gauge();
    assertThat(g.value()).isEqualTo(2d);
    g = registry.find("my_gauge").tags("address", "addr1").gauge();
    assertThat(g).isNull();
    g = registry.find("my_gauge").tags("address", "addr2").gauge();
    assertThat(g.value()).isEqualTo(1d);
}
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 4 with SimpleMeterRegistry

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

the class SummariesTest method shouldAliasSummaryLabel.

@Test
public void shouldAliasSummaryLabel() {
    MeterRegistry registry = new SimpleMeterRegistry();
    BackendRegistries.registerMatchers(registry, Collections.singletonList(new Match().setLabel("address").setType(MatchType.REGEX).setValue("addr1").setAlias("1")));
    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", "1").summary();
    assertThat(s.count()).isEqualTo(2);
    assertThat(s.totalAmount()).isEqualTo(13);
    s = registry.find("my_summary").tags("address", "addr1").summary();
    assertThat(s).isNull();
    s = registry.find("my_summary").tags("address", "addr2").summary();
    assertThat(s.count()).isEqualTo(1);
    assertThat(s.totalAmount()).isEqualTo(10);
}
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)

Example 5 with SimpleMeterRegistry

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

the class TimersTest method shouldAliasTimerLabel.

@Test
public void shouldAliasTimerLabel() {
    MeterRegistry registry = new SimpleMeterRegistry();
    BackendRegistries.registerMatchers(registry, Collections.singletonList(new Match().setLabel("address").setType(MatchType.REGEX).setValue("addr1").setAlias("1")));
    Timers timers = new Timers("my_timer", "", registry, Label.ADDRESS);
    timers.get("addr1").record(5, TimeUnit.MILLISECONDS);
    timers.get("addr1").record(8, TimeUnit.MILLISECONDS);
    timers.get("addr2").record(10, TimeUnit.MILLISECONDS);
    Timer t = registry.find("my_timer").tags("address", "1").timer();
    assertThat(t.count()).isEqualTo(2);
    assertThat(t.totalTime(TimeUnit.MILLISECONDS)).isEqualTo(13);
    t = registry.find("my_timer").tags("address", "addr1").timer();
    assertThat(t).isNull();
    t = registry.find("my_timer").tags("address", "addr2").timer();
    assertThat(t.count()).isEqualTo(1);
    assertThat(t.totalTime(TimeUnit.MILLISECONDS)).isEqualTo(10);
}
Also used : Timer(io.micrometer.core.instrument.Timer) 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

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