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