use of io.micrometer.core.instrument.MeterRegistry in project micrometer by micrometer-metrics.
the class FunctionCounterSample method main.
public static void main(String[] args) {
MeterRegistry registry = SampleConfig.myMonitoringSystem();
AtomicInteger n = new AtomicInteger(0);
FunctionCounter.builder("my.fcounter", n, AtomicInteger::get).baseUnit("happiness").description("A counter derived from a monotonically increasing value").register(registry);
Counter counter = Counter.builder("my.counter").baseUnit("happiness").description("A normal counter").register(registry);
Flux.interval(Duration.ofMillis(10)).doOnEach(i -> {
n.incrementAndGet();
counter.increment();
}).blockLast();
}
use of io.micrometer.core.instrument.MeterRegistry in project micrometer by micrometer-metrics.
the class CacheSample method main.
public static void main(String[] args) {
MeterRegistry registry = SampleConfig.myMonitoringSystem();
GuavaCacheMetrics.monitor(registry, guavaCache, "book.guava");
// read all of Frankenstein
HttpClient.create("www.gutenberg.org").get("/cache/epub/84/pg84.txt").flatMapMany(res -> res.addHandler(wordDecoder()).receive().asString()).delayElements(// one word per 10 ms
Duration.ofMillis(10)).filter(word -> !word.isEmpty()).doOnNext(word -> {
if (guavaCache.getIfPresent(word) == null)
guavaCache.put(word, 1);
}).blockLast();
}
use of io.micrometer.core.instrument.MeterRegistry in project micrometer by micrometer-metrics.
the class ClassLoaderMetricsTest method classLoadingMetrics.
@Test
void classLoadingMetrics() {
MeterRegistry registry = new SimpleMeterRegistry();
new ClassLoaderMetrics().bindTo(registry);
assertThat(registry.get("jvm.classes.loaded").gauge().value()).isGreaterThan(0);
}
use of io.micrometer.core.instrument.MeterRegistry in project micrometer by micrometer-metrics.
the class UptimeMetricsTest method uptimeMetricsMock.
@Test
void uptimeMetricsMock() {
MeterRegistry registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock());
RuntimeMXBean runtimeMXBean = mock(RuntimeMXBean.class);
when(runtimeMXBean.getUptime()).thenReturn(1337L);
when(runtimeMXBean.getStartTime()).thenReturn(4711L);
new UptimeMetrics(runtimeMXBean, emptyList()).bindTo(registry);
assertThat(registry.get("process.uptime").timeGauge().value()).isEqualTo(1.337);
assertThat(registry.get("process.start.time").timeGauge().value()).isEqualTo(4.711);
}
use of io.micrometer.core.instrument.MeterRegistry in project micrometer by micrometer-metrics.
the class UptimeMetricsTest method uptimeMetricsRuntime.
@Test
void uptimeMetricsRuntime() {
MeterRegistry registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock());
new UptimeMetrics().bindTo(registry);
registry.get("process.uptime").timeGauge();
registry.get("process.start.time").timeGauge();
}
Aggregations