Sha256: 05c8433e2d9aa989d62ae36a7aa904fa2ca69fc1c134916eee5cb943d7da058a

Contents?: true

Size: 700 Bytes

Versions: 23

Compression:

Stored size: 700 Bytes

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
  class Context
    # The Key class provides mechanisms to index and access values from a
    # Context
    class Key
      attr_reader :name

      # @api private
      # Use Context.create_key to obtain a Key instance.
      def initialize(name)
        @name = name
      end

      # 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+.
      def get(context = Context.current)
        context[self]
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
opentelemetry-api-0.12.1 lib/opentelemetry/context/key.rb
opentelemetry-api-0.12.0 lib/opentelemetry/context/key.rb
opentelemetry-api-0.11.0 lib/opentelemetry/context/key.rb