Search in sources :

Example 1 with CumulativeFunctionCounter

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

the class PrometheusMeterRegistry method newFunctionCounter.

@Override
protected <T> FunctionCounter newFunctionCounter(Meter.Id id, T obj, ToDoubleFunction<T> countFunction) {
    MicrometerCollector collector = collectorByName(id);
    FunctionCounter fc = new CumulativeFunctionCounter<>(id, obj, countFunction);
    List<String> tagValues = tagValues(id);
    collector.add((conventionName, tagKeys) -> Stream.of(new MicrometerCollector.Family(Collector.Type.COUNTER, conventionName, Stream.of(new Collector.MetricFamilySamples.Sample(conventionName, tagKeys, tagValues, fc.count())))));
    return fc;
}
Also used : Collector(io.prometheus.client.Collector) CumulativeFunctionCounter(io.micrometer.core.instrument.cumulative.CumulativeFunctionCounter) CumulativeFunctionCounter(io.micrometer.core.instrument.cumulative.CumulativeFunctionCounter)

Aggregations

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