struct Prometheus::LabelSet

Overview

LabelSet represents a collection of labels that uniquely identify a metric.

A LabelSet is used to attach multiple labels to a metric, enabling Prometheus's dimensional data model.

labels = LabelSet.new({
  "method" => "GET",
  "path"   => "/api/users",
})

LabelSets can be merged to combine labels from different sources:

base_labels = LabelSet.new({"service" => "web"})
request_labels = LabelSet.new({"method" => "GET"})
combined = base_labels.merge(request_labels)

Included Modules

Defined in:

types.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(labels : Hash(String, String) = Hash(String, String).new) #

Instance Method Detail

def ==(other : self) #

def []?(label : String) #

def add(name : String, value : String) #

def each(*args, **options) #

def each(*args, **options, &) #

def hash(hasher) #
Description copied from struct Struct

See Object#hash(hasher)


def labels : Hash(String, String) #

def merge(other : LabelSet) #

def merge(other : Hash(String, String)) #

def to_s(io : IO) #
Description copied from struct Struct

Same as #inspect(io).