Sha256: 323c962ae01cc6eadb0b038c52a6819a2a91421831a09dd9f22978d00e91dfc4

Contents?: true

Size: 1.29 KB

Versions: 63

Compression:

Stored size: 1.29 KB

Contents

module Datadog
  module OpenTracer
    # OpenTracing adapter for thread local scope management
    class ThreadLocalScopeManager < ScopeManager
      # 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)
        ThreadLocalScope.new(
          manager: self,
          span: span,
          finish_on_close: finish_on_close
        ).tap do |scope|
          set_scope(scope)
        end
      end

      # @return [Scope] the currently active Scope which can be used to access the
      # currently active Span.
      #
      # 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.
      def active
        Thread.current[object_id.to_s]
      end

      private

      def set_scope(scope)
        Thread.current[object_id.to_s] = scope
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 2 rubygems

Version Path
ddtrace-0.51.1 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.51.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.50.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.49.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.48.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.47.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.46.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.45.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.44.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.43.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.42.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.41.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ls-trace-0.2.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.40.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.39.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.38.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.37.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.36.0 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ls-trace-0.1.2 lib/ddtrace/opentracer/thread_local_scope_manager.rb
ddtrace-0.35.2 lib/ddtrace/opentracer/thread_local_scope_manager.rb