class

Crometheus::Metric::LabeledMetric(LabelType, MetricType)

Inherits Crometheus::Metric / Reference / Object

LabeledMetric is a generic type that acts as a collection of Metric objects exported under the same metric name, but with different labelsets. It takes two type parameters, one for the type of Metric to to collect, and one NamedTuple mapping label names to String values. Since this is cumbersome to type out, you generally won't refer to LabeledMetric directly in your code; instead, use Metric.[] or Crometheus.alias to generate an appropriate LabeledMetric type.

Storing labelsets as NamedTuples allows the compiler to enforce the constraint that every metric in the collection have the same set of label names.

Constructors

new(name : Symbol, docstring : String, register_with : Crometheus::Registry | Nil = Crometheus.default_registry, **metric_params)

Creates a LabeledMetric, saving **metric_params for passage to the constructors of each metric in the collection.

Source

Class methods

type

Returns MetricType.type. See Metric::Type.

Source

Instance methods

[]

Fetches the metric with the given labelset. Takes one keyword argument for each of this metric's labels.

Source
clear

Deletes all metrics from the collection.

Source
get_labels

Returns an array of every labelset currently ascribed to a metric.

Source
remove

Deletes the metric with the given labelset from the collection. Takes one keyword argument for each of this metric's labels.

Source
samples

Iteratively calls samples on each metric in the collection, yielding each received Sample. See Metric#samples.

Source