All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ringcentral.platform.metrics.micrometer.MfFunctionCounter Maven / Gradle / Ivy

There is a newer version: 4.0.0-RELEASE
Show newest version
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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy