class RSpec::Buildkite::Analytics::Tracer

Public Class Methods

new() click to toggle source
# File lib/rspec/buildkite/analytics/tracer.rb, line 28
def initialize
  @top = Span.new(:top, Concurrent.monotonic_time, nil, {})
  @stack = [@top]
end

Public Instance Methods

backfill(section, duration, **detail) click to toggle source
# File lib/rspec/buildkite/analytics/tracer.rb, line 44
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() click to toggle source
# File lib/rspec/buildkite/analytics/tracer.rb, line 49
def current_span
  @stack.last
end
enter(section, **detail) click to toggle source
# File lib/rspec/buildkite/analytics/tracer.rb, line 33
def enter(section, **detail)
  new_entry = Span.new(section, Concurrent.monotonic_time, nil, detail)
  current_span.children << new_entry
  @stack << new_entry
end
finalize() click to toggle source
# File lib/rspec/buildkite/analytics/tracer.rb, line 53
def finalize
  raise "Stack not empty" unless @stack.size == 1
  @top.end_at = Concurrent.monotonic_time
  self
end
history() click to toggle source
# File lib/rspec/buildkite/analytics/tracer.rb, line 59
def history
  @top.as_json
end
leave() click to toggle source
# File lib/rspec/buildkite/analytics/tracer.rb, line 39
def leave
  current_span.end_at = Concurrent.monotonic_time
  @stack.pop
end