Class: OpenTelemetry::Context::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/context/key.rb

Overview

The Key class provides mechanisms to index and access values from a Context

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Key

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.

Use Context.create_key to obtain a Key instance.



16
17
18
# File 'lib/opentelemetry/context/key.rb', line 16

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/opentelemetry/context/key.rb', line 12

def name
  @name
end

Instance Method Details

#get(context = Context.current) ⇒ Object

Returns the value indexed by this Key in the specified context

Parameters:

  • context (optional Context) (defaults to: Context.current)

    The Context to lookup the key from. Defaults to Context.current.



24
25
26
# File 'lib/opentelemetry/context/key.rb', line 24

def get(context = Context.current)
  context[self]
end