Class Counter
- All Implemented Interfaces:
CounterDataPoint, DataPoint, Collector
public class Counter
extends StatefulMetric<CounterDataPoint, Counter.DataPoint>
implements CounterDataPoint
Counter metric.
Example usage:
Counter requestCount = Counter.builder()
.name("requests_total")
.help("Total number of requests")
.labelNames("path", "status")
.register();
requestCount.labelValues("/hello-world", "200").inc();
requestCount.labelValues("/hello-world", "500").inc();
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Counter.Builderbuilder()static Counter.Builderbuilder(PrometheusProperties config) collect()Called when the Prometheus server scrapes metrics.doubleget()Get the current value.longGet the current value as along.voidinc(double amount) Addamount.voidinc(long amount) Addamount.voidincWithExemplar(double amount, Labels labels) Addamount, and create a custom exemplar with the given labels.voidincWithExemplar(long amount, Labels labels) Addamount, and create a custom exemplar with the given labels.Methods inherited from class StatefulMetric
clear, initLabelValues, labelValues, remove, removeIfMethods inherited from class MetricWithFixedMetadata
getPrometheusNameMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CounterDataPoint
inc, incWithExemplar
-
Method Details
-
inc
Description copied from interface:CounterDataPoint- Specified by:
incin interfaceCounterDataPoint
-
inc
Description copied from interface:CounterDataPoint- Specified by:
incin interfaceCounterDataPoint
-
incWithExemplar
Description copied from interface:CounterDataPointAddamount, and create a custom exemplar with the given labels. Throws anIllegalArgumentExceptionifamountis negative.- Specified by:
incWithExemplarin interfaceCounterDataPoint
-
incWithExemplar
Description copied from interface:CounterDataPointAddamount, and create a custom exemplar with the given labels. Throws anIllegalArgumentExceptionifamountis negative.- Specified by:
incWithExemplarin interfaceCounterDataPoint
-
get
Description copied from interface:CounterDataPointGet the current value.- Specified by:
getin interfaceCounterDataPoint
-
getLongValue
Description copied from interface:CounterDataPointGet the current value as along. Decimal places will be discarded.- Specified by:
getLongValuein interfaceCounterDataPoint
-
collect
Description copied from interface:CollectorCalled when the Prometheus server scrapes metrics.- Specified by:
collectin interfaceCollector- Overrides:
collectin classStatefulMetric<CounterDataPoint, Counter.DataPoint>
-
builder
-
builder
-