本文整理汇总了Java中io.micrometer.core.instrument.MeterRegistry.counter方法的典型用法代码示例。如果您正苦于以下问题:Java MeterRegistry.counter方法的具体用法?Java MeterRegistry.counter怎么用?Java MeterRegistry.counter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.micrometer.core.instrument.MeterRegistry
的用法示例。
在下文中一共展示了MeterRegistry.counter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: incrementAmount
import io.micrometer.core.instrument.MeterRegistry; //导入方法依赖的package包/类
@Test
@DisplayName("increment by a non-negative amount")
default void incrementAmount(MeterRegistry registry) {
Counter c = registry.counter("myCounter");
c.increment(2);
c.increment(0);
clock(registry).add(step());
assertEquals(2L, c.count());
}
示例2: main
import io.micrometer.core.instrument.MeterRegistry; //导入方法依赖的package包/类
public static void main(String[] args) {
MeterRegistry registry = SampleConfig.myMonitoringSystem();
Counter counter = registry.counter("counter");
AtomicInteger n = new AtomicInteger(0);
registry.more().counter("fcounter", emptyList(), n);
RandomEngine r = new MersenneTwister64(0);
Normal dist = new Normal(0, 1, r);
Flux.interval(Duration.ofMillis(10))
.doOnEach(d -> {
if (dist.nextDouble() + 0.1 > 0) {
counter.increment();
n.incrementAndGet();
}
})
.blockLast();
}
示例3: increment
import io.micrometer.core.instrument.MeterRegistry; //导入方法依赖的package包/类
@DisplayName("multiple increments are maintained")
@Test
default void increment(MeterRegistry registry) {
Counter c = registry.counter("myCounter");
c.increment();
clock(registry).add(step());
assertThat(c.count()).isEqualTo(1.0, offset(1e-12));
c.increment();
c.increment();
clock(registry).add(step());
// in the case of a step aggregating system will be 2, otherwise 3
assertThat(c.count()).isGreaterThanOrEqualTo(2.0);
}