Meter

abstract class Meter(val name: String, var level: Level) : CollectorRegistry.Collector

The Meter class serves as an abstract base class for creating different types of metering instruments such as Counters, UpDownCounters, and Gauges. It extends CollectorRegistry.Collector and provides specialized methods to create these instruments with specified names, units of measurement, and optional descriptions.

Parameters

name

The name of the meter.

level

The logging level for the meter.

Inheritors

Constructors

Link copied to clipboard
constructor(name: String, level: Level)

Creates an instance of Meter with the specified name and logging level.

Types

Link copied to clipboard
object Companion
Link copied to clipboard
sealed class Instrument

Represents a base instrument used for recording various types of metric data. https://opentelemetry.io/docs/specs/otel/metrics/api/#meter

Properties

Link copied to clipboard
override var level: Level
Link copied to clipboard
open override var levelBeforeMute: Level
Link copied to clipboard
override val name: String

Functions

Link copied to clipboard
fun <T : Number> counter(name: String, unit: String? = null, description: String? = null): Meter.Instrument.Counter<T>

Creates a new counter instrument with the specified name, unit, and description.

Link copied to clipboard
fun <T : Number> gauge(name: String, unit: String? = null, description: String? = null): Meter.Instrument.Gauge<T>

Creates a new gauge instrument with the specified name, unit, and description.

Link copied to clipboard
open fun isMuted(): Boolean
Link copied to clipboard
open fun mute()

Mutes the logger by setting its logging level to Level.OFF.

Link copied to clipboard
open fun unmute()

Reverts the logger to its previous logging level before it was muted.

Link copied to clipboard
fun <T : Number> upDownCounter(name: String, unit: String? = null, description: String? = null): Meter.Instrument.UpDownCounter<T>

Creates a new up-down counter instrument with the specified name, unit, and description.