Sha256: b1131c721f342a87d57ce15912f00c72bea76fe3922289aab04de72b7171c6e3

Contents?: true

Size: 874 Bytes

Versions: 22

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

module Datadog
  module OpenTracer
    # OpenTracing adapter for thread local scopes
    # @public_api
    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

22 entries across 22 versions & 1 rubygems

Version Path
ddtrace-1.23.3 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.23.2 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.23.1 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.22.0 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.21.1 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.21.0 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.20.0 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.19.0 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.18.0 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.17.0 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.16.2 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.16.1 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.16.0 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.15.0 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.14.0 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.13.1 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.13.0 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.12.1 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.12.0 lib/datadog/opentracer/thread_local_scope.rb
ddtrace-1.11.1 lib/datadog/opentracer/thread_local_scope.rb