# class Prometheus::LabelSet

- Prometheus::LabelSet
- Reference
- Object

##
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

- .new(labels : Hash(String, String) = Hash(String, String).new)

##
Instance Method Summary

- #add(name : String, value : String)
- #labels : Hash(String, String)
- #merge(other : LabelSet)
- #to_s(io : IO)

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

##
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>