• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Counter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.micrometer.core.instrument.Counter的典型用法代码示例。如果您正苦于以下问题:Java Counter类的具体用法?Java Counter怎么用?Java Counter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Counter类属于io.micrometer.core.instrument包,在下文中一共展示了Counter类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: MetricsTurboFilter

import io.micrometer.core.instrument.Counter; //导入依赖的package包/类
MetricsTurboFilter(MeterRegistry registry, Iterable<Tag> tags) {
    errorCounter = Counter.builder("logback.events")
        .tags(tags).tags("level", "error")
        .description("Number of error level events that made it to the logs")
        .register(registry);

    warnCounter = Counter.builder("logback.events")
        .tags(tags).tags("level", "warn")
        .description("Number of warn level events that made it to the logs")
        .register(registry);

    infoCounter = Counter.builder("logback.events")
        .tags(tags).tags("level", "info")
        .description("Number of info level events that made it to the logs")
        .register(registry);

    debugCounter = Counter.builder("logback.events")
        .tags(tags).tags("level", "debug")
        .description("Number of debug level events that made it to the logs")
        .register(registry);

    traceCounter = Counter.builder("logback.events")
        .tags(tags).tags("level", "trace")
        .description("Number of trace level events that made it to the logs")
        .register(registry);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:27,代码来源:LogbackMetrics.java


示例2: incrementAmount

import io.micrometer.core.instrument.Counter; //导入依赖的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());
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:11,代码来源:CounterTest.java


示例3: main

import io.micrometer.core.instrument.Counter; //导入依赖的package包/类
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();
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:23,代码来源:FunctionCounterSample.java


示例4: main

import io.micrometer.core.instrument.Counter; //导入依赖的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();
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:20,代码来源:CounterSample.java


示例5: DataSourceMetricsHolder

import io.micrometer.core.instrument.Counter; //导入依赖的package包/类
DataSourceMetricsHolder(String dataSourceName, DataSourcePoolMetadata poolMetadata, MeterRegistry registry) {
    connectionObtainTimer = Timer.builder("data.source.connections.wait")
            .tags("pool", dataSourceName)
            .register(registry);

    connectionUsageTimer = Timer.builder("data.source.connections.usage")
            .tags("pool", dataSourceName)
            .register(registry);

    connectionCreatedCounter = Counter.builder("data.source.connections.created")
            .tags("pool", dataSourceName)
            .register(registry);

    connectionFailedCounter = Counter.builder("data.source.connections.failed")
            .tags("pool", dataSourceName)
            .register(registry);

    Gauge.builder("data.source.connections.active", this, metrics -> activeConnections.doubleValue())
            .tags("pool", dataSourceName)
            .register(registry);

    Gauge.builder("data.source.connections.pending", this, metrics -> pendingConnections.doubleValue())
            .tags("pool", dataSourceName)
            .register(registry);

    if (poolMetadata != null) {
        Gauge.builder("data.source.connections.max", this, metrics -> poolMetadata.getMax())
                .tags("pool", dataSourceName)
                .register(registry);

        Gauge.builder("data.source.connections.min", this, metrics -> poolMetadata.getMin())
                .tags("pool", dataSourceName)
                .register(registry);
    }
}
 
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:36,代码来源:DataSourceMetricsHolder.java


示例6: registerNewMeter

import io.micrometer.core.instrument.Counter; //导入依赖的package包/类
@Override
Counter registerNewMeter(MeterRegistry registry) {
    return Counter.builder(getId().getName())
                  .tags(getId().getTags())
                  .description(getId().getDescription())
                  .baseUnit(getId().getBaseUnit())
                  .register(registry);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:9,代码来源:CompositeCounter.java


示例7: increment

import io.micrometer.core.instrument.Counter; //导入依赖的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);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:15,代码来源:CounterTest.java


示例8: ProteusMetricsSubscriber

import io.micrometer.core.instrument.Counter; //导入依赖的package包/类
ProteusMetricsSubscriber(CoreSubscriber<? super T> actual, Counter success, Counter error, Counter cancelled, Timer timer) {
  this.actual = actual;
  this.success = success;
  this.error = error;
  this.cancelled = cancelled;
  this.timer = timer;
}
 
开发者ID:netifi,项目名称:proteus-java,代码行数:8,代码来源:ProteusMetricsSubscriber.java


示例9: spanReporterCounterService

import io.micrometer.core.instrument.Counter; //导入依赖的package包/类
@Bean
@ConditionalOnBean(MeterRegistry.class)
public SpanMetricReporter spanReporterCounterService(SleuthMetricProperties sleuthMetricProperties,
		MeterRegistry meterRegistry) {
	Counter acceptedSpansCounter = Counter.builder(
			sleuthMetricProperties.getSpan().getAcceptedName()).register(meterRegistry);
	Counter droppedSpansCounter = Counter.builder(
			sleuthMetricProperties.getSpan().getDroppedName()).register(meterRegistry);
	return new CounterServiceBasedSpanMetricReporter(acceptedSpansCounter, droppedSpansCounter);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:11,代码来源:TraceMetricsAutoConfiguration.java


示例10: shouldIncreaseNumberOfAcceptedSpans

import io.micrometer.core.instrument.Counter; //导入依赖的package包/类
@Test
public void shouldIncreaseNumberOfAcceptedSpans() {
	Span context = this.tracer.createSpan("http:foo");
	this.tracer.close(context);
	this.listener.poll();

	Optional<Counter> counter = this.meterRegistry.find("counter.span.accepted")
			.counter();
	then(counter.isPresent()).isTrue();
	// TODO: Can't make this work in tests
	//then(counter.get().count()).isGreaterThan(0d);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:13,代码来源:StreamSpanListenerTests.java


示例11: shouldIncrement

import io.micrometer.core.instrument.Counter; //导入依赖的package包/类
@Test
public void shouldIncrement() throws Exception {
	MeterRegistry meterRegistry = mock(MeterRegistry.class);
	CounterFactory factory = new DefaultCounterFactory(meterRegistry);

	Counter counter = mock(Counter.class);
	when(meterRegistry.counter(NAME)).thenReturn(counter);

	factory.increment(NAME);

	verify(counter).increment();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:13,代码来源:DefaultCounterFactoryTests.java


示例12: newNoopMeter

import io.micrometer.core.instrument.Counter; //导入依赖的package包/类
@Override
Counter newNoopMeter() {
    return new NoopCounter(getId());
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:5,代码来源:CompositeCounter.java


示例13: SpectatorCounter

import io.micrometer.core.instrument.Counter; //导入依赖的package包/类
SpectatorCounter(Meter.Id id, com.netflix.spectator.api.Counter counter) {
    super(id);
    this.counter = counter;
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:5,代码来源:SpectatorCounter.java


示例14: doStoreFeedbackMetrics

import io.micrometer.core.instrument.Counter; //导入依赖的package包/类
protected void doStoreFeedbackMetrics(Feedback feedback, PredictiveUnitState state){
	Counter.builder("seldon_api_model_feedback_reward").tags(tagsProvider.getModelMetrics(state)).register(Metrics.globalRegistry).increment(feedback.getReward());
	Counter.builder("seldon_api_model_feedback").tags(tagsProvider.getModelMetrics(state)).register(Metrics.globalRegistry).increment();
}
 
开发者ID:SeldonIO,项目名称:seldon-core,代码行数:5,代码来源:PredictiveUnitBean.java


示例15: CounterServiceBasedSpanMetricReporter

import io.micrometer.core.instrument.Counter; //导入依赖的package包/类
public CounterServiceBasedSpanMetricReporter(Counter acceptedSpansCounter,
		Counter droppedSpansCounter) {
	this.acceptedSpansCounter = acceptedSpansCounter;
	this.droppedSpansCounter = droppedSpansCounter;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:6,代码来源:CounterServiceBasedSpanMetricReporter.java


示例16: success

import io.micrometer.core.instrument.Counter; //导入依赖的package包/类
@Override
public Counter success() {
    return success;
}
 
开发者ID:line,项目名称:armeria,代码行数:5,代码来源:RequestMetricSupport.java


示例17: failure

import io.micrometer.core.instrument.Counter; //导入依赖的package包/类
@Override
public Counter failure() {
    return failure;
}
 
开发者ID:line,项目名称:armeria,代码行数:5,代码来源:RequestMetricSupport.java


示例18: newCounter

import io.micrometer.core.instrument.Counter; //导入依赖的package包/类
@Override
protected Counter newCounter(Id id) {
    return new NoopCounter(id);
}
 
开发者ID:line,项目名称:armeria,代码行数:5,代码来源:NoopMeterRegistry.java



注:本文中的io.micrometer.core.instrument.Counter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ZlibDirectDecompressor类代码示例发布时间:2022-05-23
下一篇:
Java EmptyIterator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap