SamplerGaugeCollector

constructor(name: String, help: String, labelNames: List<String> = emptyList(), labelValues: List<String> = emptyList(), registry: PrometheusRegistry = PrometheusRegistry.defaultRegistry, data: () -> Double)

Parameters

name

the metric name. As in the Prometheus Java client 1.x, any non-empty UTF-8 string is accepted; the exposition formats escape characters outside the legacy [a-zA-Z_:][a-zA-Z0-9_:]* set.

help

the help/description text for the metric.

labelNames

the label names for the metric. Defaults to empty.

labelValues

the label values corresponding to labelNames. Defaults to empty.

registry

the registry to register with. Defaults to PrometheusRegistry.defaultRegistry.

data

a lambda that returns the current gauge value as a Double. If it throws, the gauge reports NaN for that scrape instead of failing the whole scrape. The failure is logged with its stack trace at WARN when it follows a success or differs from the previous one (by the class and message of the exception and its causes), and at DEBUG while it repeats; the next success is logged at INFO.


constructor(name: String, help: String, data: () -> Double)

Creates an unlabelled gauge registered with PrometheusRegistry.defaultRegistry.


constructor(name: String, help: String, labelNames: List<String>, labelValues: List<String>, data: () -> Double)

Creates a gauge with the given labels, registered with PrometheusRegistry.defaultRegistry.