Sha256: ac8f237c51a16b47fbaac7a26f30d8d6afbf4d7b6cda1d58f8e4f14c8c9009a5

Contents?: true

Size: 825 Bytes

Versions: 7

Compression:

Stored size: 825 Bytes

Contents

module Datadog
  module OpenTracer
    # OpenTracing adapter for thread local scopes
    class ThreadLocalScope < Scope
      attr_reader \
        :finish_on_close

      def initialize(
        manager:,
        span:,
        finish_on_close: true
      )
        super(manager: manager, span: span)
        @finish_on_close = finish_on_close
        @previous_scope = manager.active
      end

      # Mark the end of the active period for the current thread and Scope,
      # updating the ScopeManager#active in the process.
      #
      # NOTE: Calling close more than once on a single Scope instance leads to
      # undefined behavior.
      def close
        return unless equal?(manager.active)

        span.finish if finish_on_close
        manager.send(:set_scope, @previous_scope)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ddtrace-0.51.1 lib/ddtrace/opentracer/thread_local_scope.rb
ddtrace-0.51.0 lib/ddtrace/opentracer/thread_local_scope.rb
ddtrace-0.50.0 lib/ddtrace/opentracer/thread_local_scope.rb
ddtrace-0.49.0 lib/ddtrace/opentracer/thread_local_scope.rb
ddtrace-0.48.0 lib/ddtrace/opentracer/thread_local_scope.rb
ddtrace-0.47.0 lib/ddtrace/opentracer/thread_local_scope.rb
ddtrace-0.46.0 lib/ddtrace/opentracer/thread_local_scope.rb