Sha256: f662013760604e0eddb009ceb3d06cae944d6e0c5bb3fc8fa425857c699b70aa

Contents?: true

Size: 701 Bytes

Versions: 9

Compression:

Stored size: 701 Bytes

Contents

# frozen_string_literal: true

# Copyright 2019 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

9 entries across 9 versions & 1 rubygems

Version Path
opentelemetry-api-0.10.0 lib/opentelemetry/context/key.rb
opentelemetry-api-0.9.0 lib/opentelemetry/context/key.rb
opentelemetry-api-0.8.0 lib/opentelemetry/context/key.rb
opentelemetry-api-0.7.0 lib/opentelemetry/context/key.rb
opentelemetry-api-0.6.0 lib/opentelemetry/context/key.rb
opentelemetry-api-0.5.1 lib/opentelemetry/context/key.rb
opentelemetry-api-0.5.0 lib/opentelemetry/context/key.rb
opentelemetry-api-0.4.0 lib/opentelemetry/context/key.rb
opentelemetry-api-0.3.0 lib/opentelemetry/context/key.rb