use of io.micrometer.core.instrument.MeterRegistry in project micrometer by micrometer-metrics.
the class ExecutorServiceSample method main.
public static void main(String[] args) {
MeterRegistry registry = SampleConfig.myMonitoringSystem();
ScheduledExecutorService es = Executors.newSingleThreadScheduledExecutor();
new ExecutorServiceMetrics(es, "executor.sample", emptyList()).bindTo(registry);
es.scheduleWithFixedDelay(() -> Mono.delay(Duration.ofMillis(20)).block(), 0, 10, TimeUnit.MILLISECONDS);
while (true) {
}
}
use of io.micrometer.core.instrument.MeterRegistry in project micrometer by micrometer-metrics.
the class TimerMemory method main.
public static void main(String[] args) throws InterruptedException {
MeterRegistry registry = SampleRegistries.wavefront();
Timer t = null;
for (Integer i = 0; i < 80; i++) {
t = Timer.builder("my.timer").tag("index", i.toString()).sla(Stream.of(1, 150, 300, 500, 900, 1000, 1200, 1500, 2000, 3000, 4000).map(Duration::ofMillis).toArray(Duration[]::new)).publishPercentiles(0.95).percentilePrecision(1).register(registry);
}
// Breakpoint somewhere after the first couple outputs to test pause detection
// for (int i = 0; ; i = (i + 1) % 2000) {
// Thread.sleep(2);
// t.record(1, TimeUnit.MILLISECONDS);
// if (i == 1000) {
// t.takeSnapshot().outputSummary(System.out, 1e6);
// }
// }
Flux.never().blockLast();
}
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);
}
Aggregations