class Datadog::OpenTracer::ThreadLocalScope

OpenTracing adapter for thread local scopes

Attributes

finish_on_close[R]

Public Class Methods

new( manager:, span:, finish_on_close: true ) click to toggle source
Calls superclass method Datadog::OpenTracer::Scope::new
# File lib/ddtrace/opentracer/thread_local_scope.rb, line 8
def initialize(
  manager:,
  span:,
  finish_on_close: true
)
  super(manager: manager, span: span)
  @finish_on_close = finish_on_close
  @previous_scope = manager.active
end

Public Instance Methods

close() click to toggle source

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.

# File lib/ddtrace/opentracer/thread_local_scope.rb, line 23
def close
  return unless equal?(manager.active)
  span.finish if finish_on_close
  manager.send(:set_scope, @previous_scope)
end