Class: AppPerfRpm::Tracing::ManagedSpan
- Inherits:
-
Span
- Object
- Span
- AppPerfRpm::Tracing::ManagedSpan
show all
- Extended by:
- Forwardable
- Defined in:
- lib/app_perf_rpm/tracing/managed_span.rb
Instance Attribute Summary
Attributes inherited from Span
#context, #end_time, #log_entries, #operation_name, #start_time, #tags
Instance Method Summary
collapse
Methods inherited from Span
#add_tags, #exit, #get_baggage_item, #log, #log_error, #set_baggage_item, #set_tag
Constructor Details
#initialize(span, deactivate) ⇒ ManagedSpan
Returns a new instance of ManagedSpan.
10
11
12
13
14
|
# File 'lib/app_perf_rpm/tracing/managed_span.rb', line 10
def initialize(span, deactivate)
@span = span
@deactivate = deactivate.respond_to?(:call) ? deactivate : nil
@active = true
end
|
Instance Method Details
#active? ⇒ Boolean
20
21
22
|
# File 'lib/app_perf_rpm/tracing/managed_span.rb', line 20
def active?
@active
end
|
#deactivate ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/app_perf_rpm/tracing/managed_span.rb', line 24
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(opts = {}) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/app_perf_rpm/tracing/managed_span.rb', line 32
def finish(opts = {})
opts[:end_time] ||= AppPerfRpm.now
deactivate
@span.finish(end_time: opts[:end_time])
end
|
#wrapped ⇒ Object
16
17
18
|
# File 'lib/app_perf_rpm/tracing/managed_span.rb', line 16
def wrapped
@span
end
|