class ExecutionTimeline
Turns an ExecutionHistory into proportional timeline segments for the Operations list. One bar per execution: wait (queue hops + lock + engine boot, END-TO-END - it is NOT pure engine boot), then one segment per started step, gaps preserved as empty track. All math lives here; views only print.
Scale is per-row: 100% of the bar equals that execution’s own duration.
Constants
- Segment
Public Class Methods
# File app/models/execution_timeline.rb, line 14 def initialize(execution, now: Time.current) @execution = execution @now = now end
Creates the timeline for one execution.
@param execution [ExecutionHistory] the execution to lay out @param now [Time] the reference clock for open-ended segments
Public Instance Methods
Source
# File app/models/execution_timeline.rb, line 63 def bytes_processed stats_sum("processedBytes") end
Sum of Trino processed bytes across the steps’ captured metrics.
@return [Integer]
Source
# File app/models/execution_timeline.rb, line 70 def bytes_written stats_sum("physicalWrittenBytes") end
Sum of Trino physically written bytes across the steps’ captured metrics.
@return [Integer]
Source
# File app/models/execution_timeline.rb, line 77 def running? = @execution.finished_at.nil? && @execution.started_at.present?
Whether the execution is mid-flight (bar needs an open right edge).
@return [Boolean]
Source
# File app/models/execution_timeline.rb, line 24 def segments return [] if start_time.nil? || total_seconds <= 0 segs = [] segs << Segment.new(:wait, nil, wait_seconds, 0, pct(wait_seconds)) if wait_seconds.to_f.positive? started_steps.each do |step| seg_end = step.finished_at || end_reference duration = (seg_end - step.started_at).to_f kind = step.status == "failed" ? :failed_step : (step.finished_at ? :step : :open) segs << Segment.new(kind, step.operation, duration, pct(step.started_at - start_time), pct(duration)) end segs end
Timeline segments in chronological order: wait, then each started step. Steps never started (skipped/blocked/pending) do NOT produce a segment - the view marks them as a dashed tick plus a legend mention.
@return [Array<Segment>] kind is one of :wait, :step, :failed_step, :open
Source
# File app/models/execution_timeline.rb, line 43 def total_seconds return 0.0 if start_time.nil? || end_reference.nil? (end_reference - start_time).to_f.clamp(0.0, Float::INFINITY) end
Total wall-clock span the bar represents.
@return [Float] seconds; 0.0 when there is nothing to draw
Source
# File app/models/execution_timeline.rb, line 53 def wait_seconds first = first_started_step return nil if first.nil? (first.started_at - start_time).to_f.clamp(0.0, Float::INFINITY) end
End-to-end wait: creation until the first step actually began. Covers queue latency, job hops, table lock and engine boot together.
@return [Float, nil] seconds, nil when no step ever started