class OpenTelemetry::Context::Key

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

Attributes

name[R]

Public Class Methods

new(name) click to toggle source

@api private Use Context.create_key to obtain a Key instance.

# File lib/opentelemetry/context/key.rb, line 16
def initialize(name)
  @name = name
end

Public Instance Methods

get(context = Context.current) click to toggle source

Returns the value indexed by this Key in the specified context

@param [optional Context] context The Context to lookup the key from.

Defaults to +Context.current+.
# File lib/opentelemetry/context/key.rb, line 24
def get(context = Context.current)
  context[self]
end