Class: Dontbugme::Formatters::Timeline

Inherits:
Object
  • Object
show all
Defined in:
lib/dontbugme/formatters/timeline.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trace, only: nil, slow: nil) ⇒ Timeline

Returns a new instance of Timeline.



10
11
12
13
14
# File 'lib/dontbugme/formatters/timeline.rb', line 10

def initialize(trace, only: nil, slow: nil)
  @trace = trace
  @only = only&.to_sym
  @slow = slow
end

Class Method Details

.format(trace, only: nil, slow: nil) ⇒ Object



6
7
8
# File 'lib/dontbugme/formatters/timeline.rb', line 6

def self.format(trace, only: nil, slow: nil)
  new(trace, only: only, slow: slow).format
end

Instance Method Details

#formatObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dontbugme/formatters/timeline.rb', line 16

def format
  lines = []
  lines << ''
  lines << "  #{@trace.identifier}"
  lines << "  Status: #{@trace.status} | Duration: #{duration_str} | Recorded: #{time_ago}"
  lines << ''
  lines << '  TIMELINE'
  lines << '  ' + ('─' * 60)
  lines << ''
  lines << format_start_span
  lines << ''

  spans_to_show.each do |span|
    lines << format_span(span)
  end

  lines << ''
  lines << format_finish_span

  if @trace.truncated_spans_count.to_i.positive?
    lines << ''
    lines << "  ... #{@trace.truncated_spans_count} additional spans truncated"
  end

  lines << ''
  lines.join("\n")
end