Interface Collector

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 Type
    Method
    Description
    Called when the Prometheus server scrapes metrics.
    collect(Predicate<String> includedNames)
    Like collect(), but returns null if includedNames.test(name) is false.
    default String
    Override this and return null if a collector does not have a constant name, or if you don't want this library to call collect() during registration of this collector.
  • Method Details

    • collect

      Called when the Prometheus server scrapes metrics.
    • collect

      default MetricSnapshot collect(Predicate<String> includedNames)
      Like collect(), but returns null if includedNames.test(name) is false.

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

    • getPrometheusName

      Override this and return null if a collector does not have a constant name, or if you don't want this library to call collect() during registration of this collector.