struct OpenTelemetry::Attributes

Overview

Insertion-ordered telemetry attributes with unique, non-empty keys. Concurrency: immutable and safe to share.

Included Modules

Defined in:

api/attributes.cr

Constant Summary

EMPTY = new

Constructors

Instance Method Summary

Constructor Detail

def self.build(& : Builder -> ) : Attributes #

[View source]
def self.from(value : Nil) : Attributes #

[View source]
def self.from(value : Attributes) : Attributes #

[View source]
def self.from(value) : Attributes #

Converts a Hash, NamedTuple, or enumerable of key-value pairs.


[View source]
def self.new #

[View source]

Instance Method Detail

def ==(other : self) #

def []?(key : String) : AnyValue | Nil #

[View source]
def each(& : Tuple(String, AnyValue) -> ) : Nil #
Description copied from module Enumerable({String, OpenTelemetry::AnyValue})

Must yield this collection's elements to the block.


[View source]
def empty? : Bool #
Description copied from module Enumerable({String, OpenTelemetry::AnyValue})

Returns true if self does not contain any element.

([] of Int32).empty? # => true
([1]).empty?         # => false
[nil, false].empty?  # => false
  • #present? returns the inverse.

[View source]
def has_key?(key : String) : Bool #

[View source]
def hash(hasher) #
Description copied from struct Struct

See Object#hash(hasher)


def keys : Array(String) #

[View source]
def merge(other : Attributes) : Attributes #

Merges two collections. Entries in other win on duplicate keys.


[View source]
def size : Int32 #
Description copied from module Enumerable({String, OpenTelemetry::AnyValue})

Returns the number of elements in the collection.

[1, 2, 3, 4].size # => 4

[View source]
def to_h : Hash(String, AnyValue) #
Description copied from module Enumerable({String, OpenTelemetry::AnyValue})

Creates a Hash out of an Enumerable where each element is a 2 element structure (for instance a Tuple or an Array).

[[:a, :b], [:c, :d]].to_h        # => {:a => :b, :c => :d}
Tuple.new({:a, 1}, {:c, 2}).to_h # => {:a => 1, :c => 2}

[View source]