Class: Jaeger::Scope
- Inherits:
-
Object
- Object
- Jaeger::Scope
- Defined in:
- lib/jaeger/scope.rb
Overview
Scope represents an OpenTracing Scope
See www.opentracing.io for more information.
Instance Attribute Summary collapse
-
#span ⇒ Span
readonly
Return the Span scoped by this Scope.
Instance Method Summary collapse
-
#close ⇒ Object
Close scope.
-
#initialize(span, scope_stack, finish_on_close:) ⇒ Scope
constructor
A new instance of Scope.
Constructor Details
#initialize(span, scope_stack, finish_on_close:) ⇒ Scope
Returns a new instance of Scope.
8 9 10 11 12 13 |
# File 'lib/jaeger/scope.rb', line 8 def initialize(span, scope_stack, finish_on_close:) @span = span @scope_stack = scope_stack @finish_on_close = finish_on_close @closed = false end |
Instance Attribute Details
#span ⇒ Span (readonly)
Return the Span scoped by this Scope
18 19 20 |
# File 'lib/jaeger/scope.rb', line 18 def span @span end |
Instance Method Details
#close ⇒ Object
Close scope
Mark the end of the active period for the current thread and Scope, updating the ScopeManager#active in the process.
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/jaeger/scope.rb', line 24 def close raise "Tried to close already closed span: #{inspect}" if @closed @closed = true @span.finish if @finish_on_close removed_scope = @scope_stack.pop if removed_scope != self # rubocop:disable Style/GuardClause raise 'Removed non-active scope, ' \ "removed: #{removed_scope.inspect}, "\ "expected: #{inspect}" end end |