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;
}
Aggregations