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

com.ringcentral.platform.metrics.stub.StubExpirableMeterInstance Maven / Gradle / Ivy

package com.ringcentral.platform.metrics.stub;

import com.ringcentral.platform.metrics.AbstractMeter.AbstractExpirableMeterInstance;
import com.ringcentral.platform.metrics.AbstractMeter.MeasurableValueProvider;
import com.ringcentral.platform.metrics.counter.CounterInstance;
import com.ringcentral.platform.metrics.labels.LabelValue;
import com.ringcentral.platform.metrics.histogram.HistogramInstance;
import com.ringcentral.platform.metrics.measurables.AbstractMeasurableValues;
import com.ringcentral.platform.metrics.measurables.Measurable;
import com.ringcentral.platform.metrics.names.MetricName;
import com.ringcentral.platform.metrics.rate.RateInstance;
import com.ringcentral.platform.metrics.timer.TimerInstance;

import java.util.List;
import java.util.Map;

public class StubExpirableMeterInstance
    extends AbstractExpirableMeterInstance
    implements CounterInstance, TimerInstance, RateInstance, HistogramInstance {

    protected StubExpirableMeterInstance(
        MetricName name,
        List labelValues,
        boolean totalInstance,
        boolean labeledMetricTotalInstance,
        boolean levelInstance,
        Map> measurableValueProviders,
        Object meter,
        long creationTimeMs) {

        super(
            name,
            labelValues,
            totalInstance,
            labeledMetricTotalInstance,
            levelInstance,
            () -> new AbstractMeasurableValues(measurableValueProviders.keySet()) {

                @Override
                @SuppressWarnings("unchecked")
                protected  V valueOfImpl(Measurable measurable) {
                    return (V)measurableValueProviders.get(measurable).valueFor(null);
                }
            },
            measurableValueProviders,
            meter,
            creationTimeMs);
    }
}