Package io.prometheus.client
Class CollectorRegistry
- java.lang.Object
-
- io.prometheus.client.CollectorRegistry
-
public class CollectorRegistry extends Object
A registry of Collectors.The majority of users should use the
defaultRegistry
, rather than instantiating their own.Creating a registry other than the default is primarily useful for unittests, or pushing a subset of metrics to the Pushgateway from batch jobs.
-
-
Field Summary
Fields Modifier and Type Field Description static CollectorRegistry
defaultRegistry
The default registry.
-
Constructor Summary
Constructors Constructor Description CollectorRegistry()
CollectorRegistry(boolean autoDescribe)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Unregister all Collectors.Enumeration<Collector.MetricFamilySamples>
filteredMetricFamilySamples(Predicate<String> sampleNameFilter)
Enumeration of metrics wheresampleNameFilter.test(name)
returnstrue
for eachname
inCollector.MetricFamilySamples.getNames()
.Enumeration<Collector.MetricFamilySamples>
filteredMetricFamilySamples(Set<String> includedNames)
Enumeration of metrics matching the specified names.Double
getSampleValue(String name)
Returns the given value, or null if it doesn't exist.Double
getSampleValue(String name, String[] labelNames, String[] labelValues)
Returns the given value, or null if it doesn't exist.Enumeration<Collector.MetricFamilySamples>
metricFamilySamples()
Enumeration of metrics of all registered collectors.void
register(Collector m)
Register a Collector.void
unregister(Collector m)
Unregister a Collector.
-
-
-
Field Detail
-
defaultRegistry
public static final CollectorRegistry defaultRegistry
The default registry.
-
-
Constructor Detail
-
CollectorRegistry
public CollectorRegistry()
-
CollectorRegistry
public CollectorRegistry(boolean autoDescribe)
-
-
Method Detail
-
register
public void register(Collector m)
Register a Collector.A collector can be registered to multiple CollectorRegistries.
-
unregister
public void unregister(Collector m)
Unregister a Collector.
-
clear
public void clear()
Unregister all Collectors.
-
metricFamilySamples
public Enumeration<Collector.MetricFamilySamples> metricFamilySamples()
Enumeration of metrics of all registered collectors.
-
filteredMetricFamilySamples
public Enumeration<Collector.MetricFamilySamples> filteredMetricFamilySamples(Set<String> includedNames)
Enumeration of metrics matching the specified names.Note that the provided set of names will be matched against the time series name and not the metric name. For instance, to retrieve all samples from a histogram, you must include the '_count', '_sum' and '_bucket' names.
-
filteredMetricFamilySamples
public Enumeration<Collector.MetricFamilySamples> filteredMetricFamilySamples(Predicate<String> sampleNameFilter)
Enumeration of metrics wheresampleNameFilter.test(name)
returnstrue
for eachname
inCollector.MetricFamilySamples.getNames()
.- Parameters:
sampleNameFilter
- may benull
, indicating that the enumeration should contain all metrics.
-
getSampleValue
public Double getSampleValue(String name)
Returns the given value, or null if it doesn't exist.This is inefficient, and intended only for use in unittests.
-
getSampleValue
public Double getSampleValue(String name, String[] labelNames, String[] labelValues)
Returns the given value, or null if it doesn't exist.This is inefficient, and intended only for use in unittests.
-
-