Java Code Examples for io.vertx.micrometer.backends.BackendRegistries#registerMatchers()
The following examples show how to use
io.vertx.micrometer.backends.BackendRegistries#registerMatchers() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MatchersTest.java From vertx-micrometer-metrics with Apache License 2.0 | 6 votes |
@Test public void shouldFilterMetric() { MeterRegistry registry = new SimpleMeterRegistry(); BackendRegistries.registerMatchers(registry, EnumSet.allOf(Label.class), Collections.singletonList(new Match() .setLabel("address") .setType(MatchType.EQUALS) .setValue("addr1"))); Counters counters = new Counters("my_counter", "", registry, Label.EB_ADDRESS); counters.get("addr1").increment(); counters.get("addr2").increment(); Counter c = registry.find("my_counter").tags("address", "addr1").counter(); assertThat(c.count()).isEqualTo(1d); c = registry.find("my_counter").tags("address", "addr2").counter(); assertThat(c).isNull(); }
Example 2
Source File: CountersTest.java From vertx-micrometer-metrics with Apache License 2.0 | 6 votes |
@Test public void shouldAliasCounterLabel() { MeterRegistry registry = new SimpleMeterRegistry(); BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match() .setLabel("address") .setType(MatchType.REGEX) .setValue("addr1") .setAlias("1"))); Counters counters = new Counters("my_counter", "", registry, Label.EB_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); }
Example 3
Source File: CountersTest.java From vertx-micrometer-metrics with Apache License 2.0 | 6 votes |
@Test public void shouldIgnoreCounterLabel() { MeterRegistry registry = new SimpleMeterRegistry(); BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match() .setLabel("address") .setType(MatchType.REGEX) .setValue(".*") .setAlias("_"))); Counters counters = new Counters("my_counter", "", registry, Label.EB_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(); }
Example 4
Source File: SummariesTest.java From vertx-micrometer-metrics with Apache License 2.0 | 6 votes |
@Test public void shouldAliasSummaryLabel() { MeterRegistry registry = new SimpleMeterRegistry(); BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match() .setLabel("address") .setType(MatchType.REGEX) .setValue("addr1") .setAlias("1"))); Summaries summaries = new Summaries("my_summary", "", registry, Label.EB_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); }
Example 5
Source File: SummariesTest.java From vertx-micrometer-metrics with Apache License 2.0 | 6 votes |
@Test public void shouldIgnoreSummaryLabel() { MeterRegistry registry = new SimpleMeterRegistry(); BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match() .setLabel("address") .setType(MatchType.REGEX) .setValue(".*") .setAlias("_"))); Summaries summaries = new Summaries("my_summary", "", registry, Label.EB_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(); }
Example 6
Source File: GaugesTest.java From vertx-micrometer-metrics with Apache License 2.0 | 6 votes |
@Test public void shouldAliasGaugeLabel() { MeterRegistry registry = new SimpleMeterRegistry(); BackendRegistries.registerMatchers(registry, ALL_LABELS, 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.EB_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); }
Example 7
Source File: GaugesTest.java From vertx-micrometer-metrics with Apache License 2.0 | 6 votes |
@Test public void shouldIgnoreGaugeLabel() { MeterRegistry registry = new SimpleMeterRegistry(); BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match() .setLabel("address") .setType(MatchType.REGEX) .setValue(".*") .setAlias("_"))); Gauges<LongAdder> gauges = new Gauges<>("my_gauge", "", LongAdder::new, LongAdder::doubleValue, registry, Label.EB_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(); }
Example 8
Source File: TimersTest.java From vertx-micrometer-metrics with Apache License 2.0 | 6 votes |
@Test public void shouldAliasTimerLabel() { MeterRegistry registry = new SimpleMeterRegistry(); BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match() .setLabel("address") .setType(MatchType.REGEX) .setValue("addr1") .setAlias("1"))); Timers timers = new Timers("my_timer", "", registry, Label.EB_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); }
Example 9
Source File: TimersTest.java From vertx-micrometer-metrics with Apache License 2.0 | 6 votes |
@Test public void shouldIgnoreTimerLabel() { MeterRegistry registry = new SimpleMeterRegistry(); BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match() .setLabel("address") .setType(MatchType.REGEX) .setValue(".*") .setAlias("_"))); Timers timers = new Timers("my_timer", "", registry, Label.EB_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").timer(); assertThat(t.count()).isEqualTo(3); assertThat(t.totalTime(TimeUnit.MILLISECONDS)).isEqualTo(23); t = registry.find("my_timer").tags("address", "addr1").timer(); assertThat(t).isNull(); t = registry.find("my_timer").tags("address", "addr2").timer(); assertThat(t).isNull(); }
Example 10
Source File: MatchersTest.java From vertx-micrometer-metrics with Apache License 2.0 | 5 votes |
@Test public void shouldFilterDomainMetric() { MeterRegistry registry = new SimpleMeterRegistry(); BackendRegistries.registerMatchers(registry, EnumSet.allOf(Label.class), Collections.singletonList(new Match() .setLabel("address") .setDomain(MetricsDomain.EVENT_BUS) .setType(MatchType.EQUALS) .setValue("addr1"))); String metric1 = MetricsDomain.EVENT_BUS.getPrefix() + "_counter"; Counters counters1 = new Counters(metric1, "", registry, Label.EB_ADDRESS); counters1.get("addr1").increment(); counters1.get("addr2").increment(); String metric2 = "another_domain_counter"; Counters counters2 = new Counters(metric2, "", registry, Label.EB_ADDRESS); counters2.get("addr1").increment(); counters2.get("addr2").increment(); // In domain where the rule applies, filter is performed Counter c = registry.find(metric1).tags("address", "addr1").counter(); assertThat(c.count()).isEqualTo(1d); c = registry.find(metric1).tags("address", "addr2").counter(); assertThat(c).isNull(); // In other domain, no filter c = registry.find(metric2).tags("address", "addr1").counter(); assertThat(c.count()).isEqualTo(1d); c = registry.find(metric2).tags("address", "addr2").counter(); assertThat(c.count()).isEqualTo(1d); }