SamplerGaugeCollector

class SamplerGaugeCollector(name: String, help: String, labelNames: List<String> = emptyList(), labelValues: List<String> = emptyList(), data: () -> Double) : Collector

A Prometheus Collector that exposes a gauge metric whose value is obtained by invoking a sampling function on each collection cycle.

The collector automatically registers itself with the default collector registry upon construction.

Parameters

name

the metric name.

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.

data

a lambda that returns the current gauge value as a Double.

Constructors

Link copied to clipboard
constructor(name: String, help: String, labelNames: List<String> = emptyList(), labelValues: List<String> = emptyList(), data: () -> Double)

Functions

Link copied to clipboard
open override fun collect(): List<Collector.MetricFamilySamples>
open fun collect(sampleNameFilter: Predicate<String?>?): List<Collector.MetricFamilySamples?>?
Link copied to clipboard
open fun <T : Collector?> register(): T?
open fun <T : Collector?> register(registry: CollectorRegistry?): T?