class 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)

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 add(name : String, value : String) #

def labels : Hash(String, String) #

def merge(other : LabelSet) #

def to_s(io : IO) #
Description copied from class Reference

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>