class Datadog::OpenTracer::ThreadLocalScopeManager

@public_api
OpenTracing adapter for thread local scope management

def self.next_instance_id

def self.next_instance_id
  UNIQUE_INSTANCE_MUTEX.synchronize { UNIQUE_INSTANCE_GENERATOR.next }
end

def activate(span, finish_on_close: true)

Returns:
  • (Scope) - instance to control the end of the active period for the

Parameters:
  • finish_on_close (Boolean) -- whether the Span should automatically be
  • span (Span) -- the Span that should become active
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

def active

Returns:
  • (Scope) - the currently active Scope which can be used to access the
def active
  Thread.current[@thread_key]
end

def initialize(*args, &block)

def initialize(*args, &block)
  super(*args, &block)
  @thread_key = "dd_opentracer_context_#{ThreadLocalScopeManager.next_instance_id}".to_sym
end

def set_scope(scope)

def set_scope(scope)
  Thread.current[@thread_key] = scope
end