Collector

abstract class Collector(val fullName: String, val help: String, val labelNames: List<String> = emptyList(), val unit: String = "")

Abstract base class for all Prometheus metric collectors.

A collector gathers and exposes one or more MetricFamilySamples, representing the data for a specific metric (e.g., counters, gauges).

Inheritors

Constructors

Link copied to clipboard
constructor(fullName: String, help: String, labelNames: List<String> = emptyList(), unit: String = "")

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class MetricFamilySamples(val name: String, val unit: String = "", val type: Collector.Type, val help: String, val samples: List<Collector.Sample>)

Represents a metric family and all of its associated Samples.

Link copied to clipboard
class Sample(val name: String, val labelNames: List<String>, val labelValues: List<String>, val value: Double, val timestamp: Long = getCurrentMillis())

Represents a single measurement of a metric.

Link copied to clipboard

Enum representing the types of Prometheus metrics.

Properties

Link copied to clipboard

Full metric name (including any suffix or unit).

Link copied to clipboard

Description of the metric, explaining what it measures.

Link copied to clipboard

List of label names associated with this metric (e.g., "method", "status").

Link copied to clipboard
abstract val name: String

The base name of the metric (without unit suffix).

Link copied to clipboard
abstract val type: Collector.Type

The metric type (e.g., counter, gauge).

Link copied to clipboard

Unit of the metric (e.g., "seconds", "bytes").

Functions

Link copied to clipboard

Collects the current set of metric samples.

Link copied to clipboard

Returns the simple class name of the Collector instance.

Link copied to clipboard
suspend fun register(registry: CollectorRegistry = CollectorRegistry.defaultRegistry): Collector

Registers this collector in the given CollectorRegistry.