Histogram

A histogram metric that tracks the distribution of values over a set of buckets.

Parameters

fullName

The full name of the histogram.

help

A description of the histogram's purpose.

labelNames

The names of the labels for the histogram.

unit

The unit of measurement for the histogram.

includeCreatedSeries

Whether to include a _created time series.

buckets

The bucket boundaries for the histogram.

Types

Link copied to clipboard
inner class Child(buckets: List<Double>)

Represents a labeled instance of the histogram, allowing for operations on specific label sets.

Link copied to clipboard
class Timer(child: Histogram.Child, start: Long)

A utility class for measuring the duration of operations and recording the observed duration in the associated histogram.

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
open override val name: String

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

Link copied to clipboard
open override 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
fun clear()

Removes all labeled child instances and resets the no-label child (if applicable).

Link copied to clipboard

Collects the current metric samples for this histogram.

Link copied to clipboard

Retrieves the current state of the histogram without labels.

Link copied to clipboard

Returns the simple class name of the Collector instance.

Link copied to clipboard
fun labels(vararg labelValues: String): Histogram.Child

Retrieves or creates a Child associated with the given label values.

Link copied to clipboard
open override fun newChild(): Histogram.Child

Creates a new child instance. Called internally when a new label set is first seen.

Link copied to clipboard
suspend fun observe(value: Double)

Observes a value and records it in the histogram without labels.

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

Registers this collector in the given CollectorRegistry.

Link copied to clipboard
fun remove(vararg labelValues: String)

Removes the child instance associated with the given label values.

Link copied to clipboard
suspend fun time(runnable: Runnable): Double

Starts a timer for measuring the duration of an operation without labels.