Package io.prometheus.client
Class Collector.MetricFamilySamples
- java.lang.Object
-
- io.prometheus.client.Collector.MetricFamilySamples
-
- Direct Known Subclasses:
CounterMetricFamily
,GaugeMetricFamily
,SummaryMetricFamily
- Enclosing class:
- Collector
public static class Collector.MetricFamilySamples extends Object
A metric, and all of its samples.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Collector.MetricFamilySamples.Sample
A single Sample, with a unique name and set of labels.
-
Constructor Summary
Constructors Constructor Description MetricFamilySamples(String name, Collector.Type type, String help, List<Collector.MetricFamilySamples.Sample> samples)
MetricFamilySamples(String name, String unit, Collector.Type type, String help, List<Collector.MetricFamilySamples.Sample> samples)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Collector.MetricFamilySamples
filter(Predicate<String> sampleNameFilter)
String[]
getNames()
List of names that are reserved for Samples in these MetricsFamilySamples.int
hashCode()
String
toString()
-
-
-
Constructor Detail
-
MetricFamilySamples
public MetricFamilySamples(String name, Collector.Type type, String help, List<Collector.MetricFamilySamples.Sample> samples)
-
MetricFamilySamples
public MetricFamilySamples(String name, String unit, Collector.Type type, String help, List<Collector.MetricFamilySamples.Sample> samples)
-
-
Method Detail
-
filter
public Collector.MetricFamilySamples filter(Predicate<String> sampleNameFilter)
- Parameters:
sampleNameFilter
- may benull
indicating that the result contains the complete list of samples.- Returns:
- A new MetricFamilySamples containing only the Samples matching the
sampleNameFilter
, ornull
if no Sample matches.
-
getNames
public String[] getNames()
List of names that are reserved for Samples in these MetricsFamilySamples.This is used in two places:
- To check potential name collisions in
CollectorRegistry.register(Collector)
. - To check if a collector may contain metrics matching the metric name filter
in
Collector.collect(Predicate)
.
getNames()
always includes the name without suffix, even though some metrics types (like Counter) will not have a Sample with that name. The reason is that the name without suffix is used in the metadata comments (# TYPE
,# UNIT
,# HELP
), and as this name must be unique we include the name without suffix here as well. - To check potential name collisions in
-
-