Search in sources :

Example 1 with CumulativeFunctionTimer

use of io.micrometer.core.instrument.cumulative.CumulativeFunctionTimer in project micrometer by micrometer-metrics.

the class PrometheusMeterRegistry method newFunctionTimer.

@Override
protected <T> FunctionTimer newFunctionTimer(Meter.Id id, T obj, ToLongFunction<T> countFunction, ToDoubleFunction<T> totalTimeFunction, TimeUnit totalTimeFunctionUnits) {
    MicrometerCollector collector = collectorByName(id);
    FunctionTimer ft = new CumulativeFunctionTimer<>(id, obj, countFunction, totalTimeFunction, totalTimeFunctionUnits, getBaseTimeUnit());
    List<String> tagValues = tagValues(id);
    collector.add((conventionName, tagKeys) -> Stream.of(new MicrometerCollector.Family(Collector.Type.SUMMARY, conventionName, Stream.of(new Collector.MetricFamilySamples.Sample(conventionName + "_count", tagKeys, tagValues, ft.count()), new Collector.MetricFamilySamples.Sample(conventionName + "_sum", tagKeys, tagValues, ft.totalTime(TimeUnit.SECONDS))))));
    return ft;
}
Also used : Collector(io.prometheus.client.Collector) CumulativeFunctionTimer(io.micrometer.core.instrument.cumulative.CumulativeFunctionTimer) CumulativeFunctionTimer(io.micrometer.core.instrument.cumulative.CumulativeFunctionTimer)

Aggregations

CumulativeFunctionTimer (io.micrometer.core.instrument.cumulative.CumulativeFunctionTimer)1 Collector (io.prometheus.client.Collector)1