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