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 failure is logged at WARN and the gauge reports NaN for that scrape instead of failing the whole scrape.


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.