use of io.micrometer.core.instrument.MeterRegistry in project vertx-micrometer-metrics by vert-x3.
the class MetricsExamples method setupAndAccessCustomRegistry.
public void setupAndAccessCustomRegistry() {
Vertx vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MicrometerMetricsOptions().setInfluxDbOptions(// or VertxPrometheusOptions
new VertxInfluxDbOptions().setEnabled(true)).setRegistryName("my registry").setEnabled(true)));
// Later on:
MeterRegistry registry = BackendRegistries.getNow("my registry");
}
use of io.micrometer.core.instrument.MeterRegistry 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.MeterRegistry 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.MeterRegistry 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.MeterRegistry 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);
}
Aggregations