class Crometheus::Metric::LabeledMetric(LabelType, MetricType)
Overview
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 NamedTuple
s allows the compiler to enforce
the constraint that every metric in the collection have the same
set of label names.
Defined in:
crometheus/metric.crConstructors
-
.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.
Class Method Summary
-
.type
Returns
MetricType.type
.
Instance Method Summary
-
#[](**labels : **LabelType)
Fetches the metric with the given labelset.
-
#clear
Deletes all metrics from the collection.
-
#get_labels : Array(LabelType)
Returns an array of every labelset currently ascribed to a metric.
-
#remove(**labels : **LabelType)
Deletes the metric with the given labelset from the collection.
- #samples(&block : Sample -> Nil) : Nil
Instance methods inherited from class Crometheus::Metric
docstring : String
docstring,
name : Symbol
name,
samples(&block : Sample -> Nil) : Nil
samples
Constructor methods inherited from class Crometheus::Metric
new(name : Symbol, docstring : String, register_with : Crometheus::Registry | Nil = Crometheus.default_registry)
new
Class methods inherited from class Crometheus::Metric
type
type,
valid_label?(label : Symbol) : Bool
valid_label?
Constructor Detail
Creates a LabeledMetric
, saving **metric_params
for passage
to the constructors of each metric in the collection.
Class Method Detail
Instance Method Detail
Fetches the metric with the given labelset. Takes one keyword argument for each of this metric's labels.
Returns an array of every labelset currently ascribed to a metric.
Deletes the metric with the given labelset from the collection. Takes one keyword argument for each of this metric's labels.
Iteratively calls #samples
on each metric in the collection,
yielding each received Sample
.
See Metric#samples
.