io.vproxy.base.prometheus.Counter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons Show documentation
Show all versions of commons Show documentation
a commons library extracted from vproxy base module
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();
}
}