Package io.prometheus.client
Class CounterMetricFamily
- java.lang.Object
-
- io.prometheus.client.Collector.MetricFamilySamples
-
- io.prometheus.client.CounterMetricFamily
-
public class CounterMetricFamily extends Collector.MetricFamilySamples
Counter metric family, for custom collectors and exporters.Most users want a normal
Counter
instead. Example usage:class YourCustomCollector extends Collector { List<MetricFamilySamples> collect() { List<MetricFamilySamples> mfs = new ArrayList<MetricFamilySamples>(); // With no labels. mfs.add(new CounterMetricFamily("my_counter_total", "help", 42)); // With labels CounterMetricFamily labeledCounter = new CounterMetricFamily("my_other_counter_total", "help", Arrays.asList("labelname")); labeledCounter.addMetric(Arrays.asList("foo"), 4); labeledCounter.addMetric(Arrays.asList("bar"), 5); mfs.add(labeledCounter); return mfs; } }
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.prometheus.client.Collector.MetricFamilySamples
Collector.MetricFamilySamples.Sample
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.String>
labelNames
-
Constructor Summary
Constructors Constructor Description CounterMetricFamily(java.lang.String name, java.lang.String help, double value)
CounterMetricFamily(java.lang.String name, java.lang.String help, java.util.List<java.lang.String> labelNames)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CounterMetricFamily
addMetric(java.util.List<java.lang.String> labelValues, double value)
-
-
-
Method Detail
-
addMetric
public CounterMetricFamily addMetric(java.util.List<java.lang.String> labelValues, double value)
-
-