Class: Datadog::OpenTracer::ThreadLocalScopeManager
- Inherits:
-
ScopeManager
- Object
- OpenTracing::ScopeManager
- ScopeManager
- Datadog::OpenTracer::ThreadLocalScopeManager
- Defined in:
- lib/datadog/opentracer/thread_local_scope_manager.rb
Overview
OpenTracing adapter for thread local scope management
Class Method Summary collapse
Instance Method Summary collapse
-
#activate(span, finish_on_close: true) ⇒ Scope
Make a span instance active.
-
#active ⇒ Scope
currently active Span.
-
#initialize(*args, &block) ⇒ ThreadLocalScopeManager
constructor
A new instance of ThreadLocalScopeManager.
Constructor Details
#initialize(*args, &block) ⇒ ThreadLocalScopeManager
Returns a new instance of ThreadLocalScopeManager.
8 9 10 11 |
# File 'lib/datadog/opentracer/thread_local_scope_manager.rb', line 8 def initialize(*args, &block) super(*args, &block) @thread_key = "dd_opentracer_context_#{ThreadLocalScopeManager.next_instance_id}".to_sym end |
Class Method Details
.next_instance_id ⇒ Object
53 54 55 |
# File 'lib/datadog/opentracer/thread_local_scope_manager.rb', line 53 def self.next_instance_id UNIQUE_INSTANCE_MUTEX.synchronize { UNIQUE_INSTANCE_GENERATOR.next } end |
Instance Method Details
#activate(span, finish_on_close: true) ⇒ Scope
Make a span instance active.
23 24 25 26 27 28 29 30 31 |
# File 'lib/datadog/opentracer/thread_local_scope_manager.rb', line 23 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 ⇒ Scope
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.
39 40 41 |
# File 'lib/datadog/opentracer/thread_local_scope_manager.rb', line 39 def active Thread.current[@thread_key] end |