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

io.vproxy.base.prometheus.Counter Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package io.vproxy.base.prometheus;

import java.util.Map;
import java.util.concurrent.atomic.LongAdder;

public class Counter extends Metric {
    private final LongAdder adder = new LongAdder();

    public Counter(String metric, Map labels) {
        super(metric, labels);
    }

    @Override
    public String type() {
        return "counter";
    }

    @Override
    public String value() {
        return "" + longValue();
    }

    public void incr(long n) {
        adder.add(n);
    }

    public long longValue() {
        return adder.longValue();
    }

    public void clear() {
        adder.reset();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy