Class: Jaeger::ScopeManager

Inherits:
Object
  • Object
show all
Defined in:
lib/jaeger/scope_manager.rb,
lib/jaeger/scope_manager/scope_stack.rb,
lib/jaeger/scope_manager/scope_identifier.rb

Overview

ScopeManager represents an OpenTracing ScopeManager

See www.opentracing.io for more information.

The ScopeManager interface abstracts both the activation of Span instances via ScopeManager#activate and access to an active Span/Scope via ScopeManager#active

Defined Under Namespace

Classes: ScopeIdentifier, ScopeStack

Instance Method Summary collapse

Constructor Details

#initializeScopeManager

Returns a new instance of ScopeManager.



16
17
18
# File 'lib/jaeger/scope_manager.rb', line 16

def initialize
  @scope_stack = ScopeStack.new
end

Instance Method Details

#activate(span, finish_on_close: true) ⇒ Scope

Make a span instance active

Parameters:

  • span (Span)

    the Span that should become active

  • finish_on_close (Boolean) (defaults to: true)

    whether the Span should automatically be finished when Scope#close is called

Returns:

  • (Scope)

    instance to control the end of the active period for the Span. It is a programming error to neglect to call Scope#close on the returned instance.



28
29
30
31
32
33
34
# File 'lib/jaeger/scope_manager.rb', line 28

def activate(span, finish_on_close: true)
  return active if active && active.span == span

  scope = Scope.new(span, @scope_stack, finish_on_close: finish_on_close)
  @scope_stack.push(scope)
  scope
end

#activeScope

Return active scope

If there is a non-null Scope, its wrapped Span becomes an implicit parent (as Reference#CHILD_OF) of any newly-created Span at Tracer#start_active_span or Tracer#start_span time.

Returns:

  • (Scope)

    the currently active Scope which can be used to access the currently active Span.



44
45
46
# File 'lib/jaeger/scope_manager.rb', line 44

def active
  @scope_stack.peek
end