Class: SpanManager::ManagedSpan
- Inherits:
-
OpenTracing::Span
- Object
- OpenTracing::Span
- SpanManager::ManagedSpan
- Extended by:
- Forwardable
- Defined in:
- lib/spanmanager/managed_span.rb
Overview
The [SpanManager::ManagedSpan] inherits all of the OpenTracing funcionality and layers on in-process propagation capabilities.
Instance Method Summary collapse
-
#active? ⇒ Boolean
Whether the span is active or not.
-
#deactivate ⇒ Object
Mark the end of active period for the current span in this asynchronus executor and/or thread.
-
#finish(end_time: Time.now) ⇒ Object
Finishes the current span, and if not yet deactivated marks the end of the active period for the span.
-
#initialize(span, deactivate) ⇒ ManagedSpan
constructor
Initializes a new active span.
Constructor Details
#initialize(span, deactivate) ⇒ ManagedSpan
Initializes a new active span. It’s ManagedSpanSource responsibility to activate the span.
13 14 15 16 17 |
# File 'lib/spanmanager/managed_span.rb', line 13 def initialize(span, deactivate) @span = span @deactivate = deactivate.respond_to?(:call) ? deactivate : nil @active = true end |
Instance Method Details
#active? ⇒ Boolean
Returns whether the span is active or not.
20 21 22 |
# File 'lib/spanmanager/managed_span.rb', line 20 def active? @active end |
#deactivate ⇒ Object
Mark the end of active period for the current span in this asynchronus executor and/or thread. It’s safe to call the method multiple times.
26 27 28 29 30 31 32 |
# File 'lib/spanmanager/managed_span.rb', line 26 def deactivate if @active && @deactivate deactivated_span = @deactivate.call warn "ActiveSpan::SpanSource inconsistency found during deactivation" unless deactivated_span == self @active = false end end |
#finish(end_time: Time.now) ⇒ Object
Finishes the current span, and if not yet deactivated marks the end of the active period for the span.
36 37 38 39 |
# File 'lib/spanmanager/managed_span.rb', line 36 def finish(end_time: Time.now) deactivate @span.finish(end_time: end_time) end |