MCPcopy Index your code
hub / github.com/questdb/questdb / CounterImpl

Class CounterImpl

core/src/main/java/io/questdb/metrics/CounterImpl.java:33–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31import java.util.concurrent.atomic.LongAdder;
32
33public class CounterImpl implements Counter {
34 private final LongAdder counter;
35 private final CharSequence name;
36
37 public CounterImpl(CharSequence name) {
38 this.name = name;
39 this.counter = new LongAdder();
40 }
41
42 @Override
43 public void add(long value) {
44 counter.add(value);
45 }
46
47 @Override
48 public long getValue() {
49 return counter.sum();
50 }
51
52 @Override
53 public void reset() {
54 counter.reset();
55 }
56
57 @Override
58 public void scrapeIntoPrometheus(@NotNull BorrowableUtf8Sink sink) {
59 PrometheusFormatUtils.appendCounterType(name, sink);
60 PrometheusFormatUtils.appendCounterNamePrefix(name, sink);
61 PrometheusFormatUtils.appendSampleLineSuffix(sink, counter.longValue());
62 PrometheusFormatUtils.appendNewLine(sink);
63 }
64}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…