Class: Datadog::OpenTracer::ThreadLocalScope
- Defined in:
- lib/datadog/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.
11 12 13 14 15 16 17 18 19 |
# File 'lib/datadog/opentracer/thread_local_scope.rb', line 11 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.
8 9 10 |
# File 'lib/datadog/opentracer/thread_local_scope.rb', line 8 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.
26 27 28 29 30 31 |
# File 'lib/datadog/opentracer/thread_local_scope.rb', line 26 def close return unless equal?(manager.active) span.finish if finish_on_close manager.send(:set_scope, @previous_scope) end |