| 31 | import java.util.concurrent.atomic.LongAdder; |
| 32 | |
| 33 | public 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…