Class: Datadog::OpenTracer::ThreadLocalScope
- Defined in:
- lib/ddtrace/opentracer/thread_local_scope.rb
Overview
OpenTracing adapter for thread local scopes
Instance Attribute Summary collapse
-
#finish_on_close ⇒ Object
readonly
Returns the value of attribute finish_on_close.
Attributes inherited from Scope
Instance Method Summary collapse
-
#close ⇒ Object
Mark the end of the active period for the current thread and Scope, updating the ScopeManager#active in the process.
-
#initialize(manager:, span:, finish_on_close: true) ⇒ ThreadLocalScope
constructor
A new instance of ThreadLocalScope.
Constructor Details
#initialize(manager:, span:, finish_on_close: true) ⇒ ThreadLocalScope
Returns a new instance of ThreadLocalScope.
8 9 10 11 12 13 14 15 16 |
# 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 |
Instance Attribute Details
#finish_on_close ⇒ Object (readonly)
Returns the value of attribute finish_on_close.
5 6 7 |
# File 'lib/ddtrace/opentracer/thread_local_scope.rb', line 5 def finish_on_close @finish_on_close end |
Instance Method Details
#close ⇒ Object
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.
23 24 25 26 27 |
# 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 |