Class CollectorRegistry
java.lang.Object
io.prometheus.client.CollectorRegistry
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanstatic final CollectorRegistryThe default registry.private final Object -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidassertNoDuplicateNames(Collector m, List<String> names) voidclear()Unregister all Collectors.A snapshot of the current collectors.filteredMetricFamilySamples(Predicate<String> sampleNameFilter) Enumeration of metrics wheresampleNameFilter.test(name)returnstruefor eachnameinCollector.MetricFamilySamples.getNames().filteredMetricFamilySamples(Set<String> includedNames) Enumeration of metrics matching the specified names.getSampleValue(String name) Returns the given value, or null if it doesn't exist.getSampleValue(String name, String[] labelNames, String[] labelValues) Returns the given value, or null if it doesn't exist.Enumeration of metrics of all registered collectors.voidRegister a Collector.voidUnregister a Collector.
-
Field Details
-
defaultRegistry
The default registry. -
namesCollectorsLock
-
collectorsToNames
-
namesToCollectors
-
autoDescribe
private final boolean autoDescribe
-
-
Constructor Details
-
CollectorRegistry
public CollectorRegistry() -
CollectorRegistry
public CollectorRegistry(boolean autoDescribe)
-
-
Method Details
-
register
Register a Collector.A collector can be registered to multiple CollectorRegistries.
-
assertNoDuplicateNames
-
unregister
Unregister a Collector. -
clear
public void clear()Unregister all Collectors. -
collectors
-
collectorNames
-
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)returnstruefor eachnameinCollector.MetricFamilySamples.getNames().- Parameters:
sampleNameFilter- may benull, indicating that the enumeration should contain all metrics.
-
getSampleValue
-
getSampleValue
-