Class PrometheusRegistry
java.lang.Object
io.prometheus.metrics.model.registry.PrometheusRegistry
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classStores the registration details for a Collector at registration time.private static classStores the registration details for a single metric within a MultiCollector.private static classTracks registration information for each metric name to enable validation of type consistency, label schema uniqueness, and help/unit consistency. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentHashMap<Collector, PrometheusRegistry.CollectorRegistration> static final PrometheusRegistryprivate final Set<MultiCollector> private final ConcurrentHashMap<String, PrometheusRegistry.RegistrationInfo> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()immutableLabelNames(Set<String> labelNames) Returns an immutable set of label names for storage.voidvoidregister(MultiCollector collector) scrape()scrape(PrometheusScrapeRequest scrapeRequest) scrape(Predicate<String> includedNames, PrometheusScrapeRequest scrapeRequest) voidunregister(Collector collector) voidunregister(MultiCollector collector) private voidunregisterLabelSchema(String prometheusName, Set<String> labelNames) Removes the label schema for the given metric name.private voidvalidateRegistration(String prometheusName, MetricType metricType, Set<String> normalizedLabels, String help, Unit unit) Validates the registration of a metric with the given parameters.
-
Field Details
-
defaultRegistry
-
collectors
-
multiCollectors
-
registered
-
collectorMetadata
private final ConcurrentHashMap<Collector,PrometheusRegistry.CollectorRegistration> collectorMetadata -
multiCollectorMetadata
private final ConcurrentHashMap<MultiCollector,List<PrometheusRegistry.MultiCollectorRegistration>> multiCollectorMetadata
-
-
Constructor Details
-
PrometheusRegistry
public PrometheusRegistry()
-
-
Method Details
-
immutableLabelNames
Returns an immutable set of label names for storage. Defends against mutation of the set returned byCollector.getLabelNames()after registration, which would break duplicate detection and unregistration. -
validateRegistration
private void validateRegistration(String prometheusName, MetricType metricType, Set<String> normalizedLabels, String help, Unit unit) Validates the registration of a metric with the given parameters. Ensures type consistency, label schema uniqueness, and help/unit consistency. -
register
-
register
-
unregister
-
unregister
-
unregisterLabelSchema
Removes the label schema for the given metric name. If no label schemas remain for that name, removes the metric name entirely from the registry. -
clear
public void clear() -
scrape
-
scrape
-
scrape
-
scrape
public MetricSnapshots scrape(Predicate<String> includedNames, PrometheusScrapeRequest scrapeRequest)
-