Class: RSpec::Buildkite::Analytics::Tracer
- Inherits:
-
Object
- Object
- RSpec::Buildkite::Analytics::Tracer
- Defined in:
- lib/rspec/buildkite/analytics/tracer.rb
Defined Under Namespace
Classes: Span
Instance Method Summary collapse
- #backfill(section, duration, **detail) ⇒ Object
- #current_span ⇒ Object
- #enter(section, **detail) ⇒ Object
- #finalize ⇒ Object
- #history ⇒ Object
-
#initialize ⇒ Tracer
constructor
A new instance of Tracer.
- #leave ⇒ Object
Constructor Details
Instance Method Details
#backfill(section, duration, **detail) ⇒ Object
46 47 48 49 |
# File 'lib/rspec/buildkite/analytics/tracer.rb', line 46 def backfill(section, duration, **detail) new_entry = Span.new(section, Concurrent.monotonic_time - duration, Concurrent.monotonic_time, detail) current_span.children << new_entry end |
#current_span ⇒ Object
51 52 53 |
# File 'lib/rspec/buildkite/analytics/tracer.rb', line 51 def current_span @stack.last end |
#enter(section, **detail) ⇒ Object
35 36 37 38 39 |
# File 'lib/rspec/buildkite/analytics/tracer.rb', line 35 def enter(section, **detail) new_entry = Span.new(section, Concurrent.monotonic_time, nil, detail) current_span.children << new_entry @stack << new_entry end |
#finalize ⇒ Object
55 56 57 58 59 |
# File 'lib/rspec/buildkite/analytics/tracer.rb', line 55 def finalize raise "Stack not empty" unless @stack.size == 1 @top.end_at = Concurrent.monotonic_time self end |
#history ⇒ Object
61 62 63 |
# File 'lib/rspec/buildkite/analytics/tracer.rb', line 61 def history @top.as_hash end |
#leave ⇒ Object
41 42 43 44 |
# File 'lib/rspec/buildkite/analytics/tracer.rb', line 41 def leave current_span.end_at = Concurrent.monotonic_time @stack.pop end |