Class: LightStep::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/lightstep/scope.rb

Overview

Scope represents an OpenTracing Scope

See www.opentracing.io for more information.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manager:, span:, finish_on_close: true) ⇒ Scope

Returns a new instance of Scope.



8
9
10
11
12
# File 'lib/lightstep/scope.rb', line 8

def initialize(manager:, span:, finish_on_close: true)
  @manager = manager
  @span = span
  @finish_on_close = finish_on_close
end

Instance Attribute Details

#spanObject (readonly)

Returns the value of attribute span.



6
7
8
# File 'lib/lightstep/scope.rb', line 6

def span
  @span
end

Instance Method Details

#closeObject

Mark the end of the active period for the current thread and Scope, updating the ScopeManager#active in the process.

Raises:



16
17
18
19
20
21
# File 'lib/lightstep/scope.rb', line 16

def close
  raise(LightStep::Error, 'already closed') if @closed
  @closed = true
  @span.finish if @finish_on_close
  @manager.deactivate
end