Sha256: 9fa5dcac0780df7f28f73baa789f1ce410ee8c20c165b8cfa75b873355f57ced

Contents?: true

Size: 1.62 KB

Versions: 9

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

require_relative 'scope_manager/scope_stack'
require_relative 'scope_manager/scope_identifier'

module Jaeger
  module Client
    # ScopeManager represents an OpenTracing ScopeManager
    #
    # See http://www.opentracing.io for more information.
    #
    # The ScopeManager interface abstracts both the activation of Span instances
    # via ScopeManager#activate and access to an active Span/Scope via
    # ScopeManager#active
    #
    class ScopeManager
      def initialize
        @scope_stack = ScopeStack.new
      end

      # Make a span instance active
      #
      # @param span [Span] the Span that should become active
      # @param finish_on_close [Boolean] whether the Span should automatically be
      #   finished when Scope#close is called
      # @return [Scope] instance to control the end of the active period for the
      #  Span. It is a programming error to neglect to call Scope#close on the
      #  returned instance.
      def activate(span, finish_on_close: true)
        return active if active && active.span == span
        scope = Scope.new(span, @scope_stack, finish_on_close: finish_on_close)
        @scope_stack.push(scope)
        scope
      end

      # Return active scope
      #
      # If there is a non-null Scope, its wrapped Span becomes an implicit parent
      # (as Reference#CHILD_OF) of any newly-created Span at
      # Tracer#start_active_span or Tracer#start_span time.
      #
      # @return [Scope] the currently active Scope which can be used to access the
      #   currently active Span.
      def active
        @scope_stack.peek
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
jaeger-client-0.9.0 lib/jaeger/client/scope_manager.rb
jaeger-client-0.8.0 lib/jaeger/client/scope_manager.rb
jaeger-client-0.7.1 lib/jaeger/client/scope_manager.rb
jaeger-client-0.7.0 lib/jaeger/client/scope_manager.rb
jaeger-client-0.6.1 lib/jaeger/client/scope_manager.rb
boost-jaeger-client-0.7.1 lib/jaeger/client/scope_manager.rb
boost-jaeger-client-0.7.0 lib/jaeger/client/scope_manager.rb
jaeger-client-0.6.0 lib/jaeger/client/scope_manager.rb
jaeger-client-0.5.0 lib/jaeger/client/scope_manager.rb