com.ringcentral.platform.metrics.micrometer.MfFunctionCounter Maven / Gradle / Ivy
package com.ringcentral.platform.metrics.micrometer;
import com.ringcentral.platform.metrics.MetricRegistry;
import io.micrometer.core.instrument.*;
import java.util.function.ToDoubleFunction;
public class MfFunctionCounter extends AbstractMeter implements MfMeter, FunctionCounter {
private final MfLongGauge gauge;
public MfFunctionCounter(
MetricRegistry mfRegistry,
Id id,
ToDoubleFunction fun,
A funArg) {
super(id);
this.gauge = new MfLongGauge<>(
mfRegistry,
id,
a -> (long)fun.applyAsDouble(funArg),
funArg,
true);
}
@Override
public double count() {
return gauge.value();
}
@Override
public void meterRemoved() {
gauge.meterRemoved();
}
}