Sha256: b9b5b2758cdf5bad95a22f2e98b625cc90af71509b073d1fc6f00724889f000f

Contents?: true

Size: 658 Bytes

Versions: 8

Compression:

Stored size: 658 Bytes

Contents

# frozen_string_literal: true

module Zipkin
  class ScopeManager
    # @api private
    class ScopeStack
      def initialize
        # Generate a random identifier to use as the Thread.current key. This is
        # needed so that it would be possible to create multiple tracers in one
        # thread (mostly useful for testing purposes)
        @scope_identifier = ScopeIdentifier.generate
      end

      def push(scope)
        store << scope
      end

      def pop
        store.pop
      end

      def peek
        store.last
      end

      private

      def store
        Thread.current[@scope_identifier] ||= []
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
zipkin-1.6.3 lib/zipkin/scope_manager/scope_stack.rb
zipkin-1.6.2 lib/zipkin/scope_manager/scope_stack.rb
zipkin-1.6.1 lib/zipkin/scope_manager/scope_stack.rb
zipkin-1.6.0 lib/zipkin/scope_manager/scope_stack.rb
zipkin-1.5.2 lib/zipkin/scope_manager/scope_stack.rb
zipkin-1.5.1 lib/zipkin/scope_manager/scope_stack.rb
zipkin-1.5.0 lib/zipkin/scope_manager/scope_stack.rb
zipkin-1.4.0 lib/zipkin/scope_manager/scope_stack.rb