Class: SpanManager::Tracer
- Inherits:
-
OpenTracing::Tracer
- Object
- OpenTracing::Tracer
- SpanManager::Tracer
- Extended by:
- Forwardable
- Defined in:
- lib/spanmanager/tracer.rb
Overview
Convenience [OpenTracing::Tracer] that automates managing current span.
It’s a wrapper that forwards all calls to another [OpenTracing::Tracer] implementation. Spans created with this tracer are automatically activated when started, and deactivated when they finish.
Instance Attribute Summary collapse
-
#managed_span_source ⇒ SpanManager::ManagedSpanSource
readonly
Returns the active span source.
Instance Method Summary collapse
-
#active_span ⇒ SpanManager::ManagedSpan
Retrieves the current active span.
-
#initialize(tracer, managed_span_source = ThreadLocalManagedSpanSource.new) ⇒ Tracer
constructor
A new instance of Tracer.
-
#start_span(operation_name, child_of: active_span, **args) ⇒ SpanManager::ManagedSpan
Starts a new active span.
-
#wrapped ⇒ OpenTracing::Tracer
The wrapped tracer.
Constructor Details
#initialize(tracer, managed_span_source = ThreadLocalManagedSpanSource.new) ⇒ Tracer
Returns a new instance of Tracer.
16 17 18 19 |
# File 'lib/spanmanager/tracer.rb', line 16 def initialize(tracer, managed_span_source = ThreadLocalManagedSpanSource.new) @tracer = tracer @managed_span_source = managed_span_source end |
Instance Attribute Details
#managed_span_source ⇒ SpanManager::ManagedSpanSource (readonly)
Returns the active span source
12 13 14 |
# File 'lib/spanmanager/tracer.rb', line 12 def managed_span_source @managed_span_source end |
Instance Method Details
#active_span ⇒ SpanManager::ManagedSpan
Retrieves the current active span.
29 30 31 |
# File 'lib/spanmanager/tracer.rb', line 29 def active_span managed_span_source.active_span end |
#start_span(operation_name, child_of: active_span, **args) ⇒ SpanManager::ManagedSpan
Starts a new active span.
42 43 44 45 |
# File 'lib/spanmanager/tracer.rb', line 42 def start_span(operation_name, child_of: active_span, **args) span = @tracer.start_span(operation_name, child_of: child_of, **args) @managed_span_source.make_active(span) end |
#wrapped ⇒ OpenTracing::Tracer
Returns the wrapped tracer.
22 23 24 |
# File 'lib/spanmanager/tracer.rb', line 22 def wrapped @tracer end |