Class: OpenTelemetry::Baggage::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/baggage/builder.rb

Overview

Operational implementation of Baggage::Builder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entries) ⇒ Builder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Builder.



15
16
17
# File 'lib/opentelemetry/baggage/builder.rb', line 15

def initialize(entries)
  @entries = entries
end

Instance Attribute Details

#entriesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/opentelemetry/baggage/builder.rb', line 12

def entries
  @entries
end

Instance Method Details

#clearObject

Clears all baggage from the to-be-created baggage



39
40
41
# File 'lib/opentelemetry/baggage/builder.rb', line 39

def clear
  @entries.clear
end

#remove_value(key) ⇒ Object

Removes key from the to-be-created baggage

Parameters:

  • key (String)

    The key to remove



34
35
36
# File 'lib/opentelemetry/baggage/builder.rb', line 34

def remove_value(key)
  @entries.delete(key)
end

#set_value(key, value, metadata: nil) ⇒ Object

Set key-value in the to-be-created baggage

Parameters:

  • key (String)

    The key to store this value under

  • value (String)

    String value to be stored under key

  • metadata (optional String) (defaults to: nil)

    This is here to store properties received from other W3C Baggage implementations but is not exposed in OpenTelemetry. This is condsidered private API and not for use by end-users.



27
28
29
# File 'lib/opentelemetry/baggage/builder.rb', line 27

def set_value(key, value, metadata: nil)
  @entries[key] = OpenTelemetry::Baggage::Entry.new(value, )
end