Interface Collector
- All Known Implementing Classes:
Counter
,CounterWithCallback
,Gauge
,GaugeWithCallback
,Histogram
,Info
,Metric
,MetricWithFixedMetadata
,StateSet
,Summary
,SummaryWithCallback
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
To be registered with the Prometheus collector registry. See Overall Structure on https://prometheus.io/docs/instrumenting/writing_clientlibs/.
-
Method Summary
Modifier and TypeMethodDescriptioncollect()
Called when the Prometheus server scrapes metrics.default MetricSnapshot
collect
(PrometheusScrapeRequest scrapeRequest) Provides Collector with the details of the request issued by Prometheus to allow multi-target pattern implementation Override to implement request dependent logic to provide MetricSnapshotdefault MetricSnapshot
default MetricSnapshot
collect
(Predicate<String> includedNames, PrometheusScrapeRequest scrapeRequest) Likecollect(Predicate)
, but with support for multi-target pattern.default String
This is called in two places: During registration to check if a metric with that name already exists.
-
Method Details
-
collect
Called when the Prometheus server scrapes metrics. -
collect
Provides Collector with the details of the request issued by Prometheus to allow multi-target pattern implementation Override to implement request dependent logic to provide MetricSnapshot -
collect
Likecollect()
, but returnsnull
ifincludedNames.test(name)
isfalse
.Override this if there is a more efficient way than first collecting the snapshot and then discarding it.
-
collect
default MetricSnapshot collect(Predicate<String> includedNames, PrometheusScrapeRequest scrapeRequest) Likecollect(Predicate)
, but with support for multi-target pattern.Override this if there is a more efficient way than first collecting the snapshot and then discarding it.
-
getPrometheusName
This is called in two places:- During registration to check if a metric with that name already exists.
- During scrape to check if this collector can be skipped because a name filter is present and the metric name is excluded.
null
means checks are omitted (registration the metric always succeeds), and the collector is always scraped (the result is dropped after scraping if a name filter is present and the metric name is excluded).If your metric has a name that does not change at runtime it is a good idea to overwrite this and return the name.
All metrics in
prometheus-metrics-core
override this.
-