当前位置: 首页>>代码示例>>Java>>正文


Java FunctionTimer类代码示例

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


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

示例1: publish

import io.micrometer.core.instrument.FunctionTimer; //导入依赖的package包/类
@Override
protected void publish() {
    List<Metric> metrics = getMeters().stream()
        .flatMap(meter -> {
            if (meter instanceof DistributionSummary) {
                return getMetrics((DistributionSummary) meter);
            } else if (meter instanceof FunctionTimer) {
                return getMetrics((FunctionTimer) meter);
            } else if (meter instanceof Timer) {
                return getMetrics((Timer) meter);
            } else {
                return getMetrics(meter);
            }
        })
        .collect(Collectors.toList());

    this.metricPublisher.publish(metrics);
}
 
开发者ID:cloudfoundry,项目名称:java-buildpack-metric-writer,代码行数:19,代码来源:MicrometerMetricWriter.java

示例2: registerNewMeter

import io.micrometer.core.instrument.FunctionTimer; //导入依赖的package包/类
@Override
FunctionTimer registerNewMeter(MeterRegistry registry) {
    final T obj = ref.get();
    if (obj == null) {
        return null;
    }

    return FunctionTimer.builder(getId().getName(), obj, countFunction,
                                 totalTimeFunction, totalTimeFunctionUnits)
                        .tags(getId().getTags())
                        .description(getId().getDescription())
                        .baseUnit(getId().getBaseUnit()).register(registry);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:14,代码来源:CompositeFunctionTimer.java

示例3: main

import io.micrometer.core.instrument.FunctionTimer; //导入依赖的package包/类
public static void main(String[] args) {
    MeterRegistry registry = SampleConfig.myMonitoringSystem();
    Timer timer = Timer.builder("timer")
        .publishPercentileHistogram()
        .publishPercentiles(0.5, 0.95, 0.99)
        .histogramExpiry(Duration.ofSeconds(10))
        .histogramBufferLength(3)
        .register(registry);

    FunctionTimer.builder("ftimer", timer, Timer::count, t -> t.totalTime(TimeUnit.SECONDS), TimeUnit.SECONDS)
        .register(registry);

    RandomEngine r = new MersenneTwister64(0);
    Normal incomingRequests = new Normal(0, 1, r);
    Normal duration = new Normal(250, 50, r);

    AtomicInteger latencyForThisSecond = new AtomicInteger(duration.nextInt());
    Flux.interval(Duration.ofSeconds(1))
        .doOnEach(d -> latencyForThisSecond.set(duration.nextInt()))
        .subscribe();

    // the potential for an "incoming request" every 10 ms
    Flux.interval(Duration.ofMillis(10))
            .doOnEach(d -> {
                if (incomingRequests.nextDouble() + 0.4 > 0) {
                    // pretend the request took some amount of time, such that the time is
                    // distributed normally with a mean of 250ms
                    timer.record(latencyForThisSecond.get(), TimeUnit.MILLISECONDS);
                }
            })
            .blockLast();
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:33,代码来源:TimerSample.java

示例4: main

import io.micrometer.core.instrument.FunctionTimer; //导入依赖的package包/类
/**
 * For Atlas: http://localhost:7101/api/v1/graph?q=name,ftimer,:eq,:dist-avg,name,timer,:eq,:dist-avg,1,:axis&s=e-5m&l=0
 */
public static void main(String[] args) {
    MeterRegistry registry = SampleConfig.myMonitoringSystem();

    Timer timer = Timer.builder("timer")
        .publishPercentiles(0.5, 0.95)
        .register(registry);

    Object placeholder = new Object();
    AtomicLong totalTimeNanos = new AtomicLong(0);
    AtomicLong totalCount = new AtomicLong(0);

    FunctionTimer.builder("ftimer", placeholder, p -> totalCount.get(), p -> totalTimeNanos.get(), TimeUnit.NANOSECONDS)
        .register(registry);

    RandomEngine r = new MersenneTwister64(0);
    Normal incomingRequests = new Normal(0, 1, r);
    Normal duration = new Normal(250, 50, r);

    AtomicInteger latencyForThisSecond = new AtomicInteger(duration.nextInt());
    Flux.interval(Duration.ofSeconds(1))
        .doOnEach(d -> latencyForThisSecond.set(duration.nextInt()))
        .subscribe();

    // the potential for an "incoming request" every 10 ms
    Flux.interval(Duration.ofMillis(10))
        .doOnEach(d -> {
            if (incomingRequests.nextDouble() + 0.4 > 0) {
                // pretend the request took some amount of time, such that the time is
                // distributed normally with a mean of 250ms
                timer.record(latencyForThisSecond.get(), TimeUnit.MILLISECONDS);
                totalCount.incrementAndGet();
                totalTimeNanos.addAndGet((long) TimeUtils.millisToUnit(latencyForThisSecond.get(), TimeUnit.NANOSECONDS));
            }
        })
        .blockLast();
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:40,代码来源:FunctionTimerSample.java

示例5: getMetrics

import io.micrometer.core.instrument.FunctionTimer; //导入依赖的package包/类
private Stream<Metric> getMetrics(FunctionTimer meter) {
    return Stream.of(
        toMetric(withStatistic(meter, "count"), meter.count()),
        toMetric(withStatistic(meter, "mean"), meter.mean(getBaseTimeUnit())),
        toMetric(withStatistic(meter, "totalTime"), meter.totalTime(getBaseTimeUnit()))
    );
}
 
开发者ID:cloudfoundry,项目名称:java-buildpack-metric-writer,代码行数:8,代码来源:MicrometerMetricWriter.java

示例6: newNoopMeter

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

示例7: newFunctionTimer

import io.micrometer.core.instrument.FunctionTimer; //导入依赖的package包/类
@Override
protected <T> FunctionTimer newFunctionTimer(Id id, T obj, ToLongFunction<T> countFunction,
                                             ToDoubleFunction<T> totalTimeFunction,
                                             TimeUnit totalTimeFunctionUnits) {
    return new NoopFunctionTimer(id);
}
 
开发者ID:line,项目名称:armeria,代码行数:7,代码来源:NoopMeterRegistry.java


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