Interface MultiCollector

All Known Implementing Classes:
CacheMetricsCollector, CacheMetricsCollector, DropwizardExports, SimpleclientCollector
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

Like Collector, but collecting multiple Snapshots at once.
  • Method Summary

    Modifier and Type
    Method
    Description
    Called when the Prometheus server scrapes metrics.
    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(Predicate<String> includedNames)
    Like collect(), but returns only the snapshots where includedNames.test(name) is true.
    collect(Predicate<String> includedNames, PrometheusScrapeRequest scrapeRequest)
    Like collect(Predicate), but with support for multi-target pattern.
    default List<String>
    This is called in two places: During registration to check if a metric with that name already exists. During scrape to check if the collector can be skipped because a name filter is present and all names are excluded. Returning an empty list means checks are omitted (registration metric always succeeds), and the collector is always scraped (if a name filter is present and all names are excluded the result is dropped).
  • 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

      default MetricSnapshots collect(Predicate<String> includedNames)
      Like collect(), but returns only the snapshots where includedNames.test(name) is true.

      Override this if there is a more efficient way than first collecting all snapshot and then discarding the excluded ones.

    • collect

      default MetricSnapshots collect(Predicate<String> includedNames, PrometheusScrapeRequest scrapeRequest)
      Like collect(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.

    • getPrometheusNames

      This is called in two places:
      1. During registration to check if a metric with that name already exists.
      2. During scrape to check if the collector can be skipped because a name filter is present and all names are excluded.
      Returning an empty list means checks are omitted (registration metric always succeeds), and the collector is always scraped (if a name filter is present and all names are excluded the result is dropped).

      If your collector returns a constant list of metrics that have names that do not change at runtime it is a good idea to overwrite this and return the names.