class Datadog::OpenTracer::ThreadLocalScopeManager

OpenTracing adapter for thread local scope management

Public Instance Methods

activate(span, finish_on_close: true) click to toggle source

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.
# File lib/ddtrace/opentracer/thread_local_scope_manager.rb, line 13
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
active() click to toggle source

@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.

# File lib/ddtrace/opentracer/thread_local_scope_manager.rb, line 29
def active
  Thread.current[object_id.to_s]
end

Private Instance Methods

set_scope(scope) click to toggle source
# File lib/ddtrace/opentracer/thread_local_scope_manager.rb, line 35
def set_scope(scope)
  Thread.current[object_id.to_s] = scope
end