Module: Wurk::Web::Enterprise::Historical

Defined in:
lib/wurk/web/enterprise.rb

Overview

Historical tab — per-class and per-queue gauges over a recent window. The minute / hour HASH layout comes from Wurk::Metrics::History; Query.for_job / Query.top_jobs already does the fan-out. The wrapper here is a stable entry point so the controller doesn't reach into the Query module directly (and so we have one place to layer additional aggregations on later — global gauges across all classes).

Class Method Summary collapse

Class Method Details

.for_job(klass, minutes: nil, hours: nil, now: ::Time.now) ⇒ Object

Per-class time series. Pass exactly one of minutes: / hours:. Returns [{at: Time, p:, f:, ms:}, …] ordered oldest→newest.



141
142
143
# File 'lib/wurk/web/enterprise.rb', line 141

def for_job(klass, minutes: nil, hours: nil, now: ::Time.now)
  Wurk::Metrics::Query.for_job(klass, minutes: minutes, hours: hours, now: now)
end

.history(bucket, window:, now: ::Time.now) ⇒ Object

Cluster-total time-series for the dashboard charts. bucket is '1m'/'5m'/'1h'; window is in seconds (clamped to the bucket's retention). Returns [{at:, p:, f:, ms:}, …] oldest→newest.



154
155
156
# File 'lib/wurk/web/enterprise.rb', line 154

def history(bucket, window:, now: ::Time.now)
  Wurk::Metrics::Query.history(bucket, window, now: now)
end

.queue_history(bucket, window:, queues: nil, now: ::Time.now) ⇒ Object

Per-queue size/latency gauge time-series for the Historical tab. bucket is '1m'/'5m'/'1h'; window is in seconds (clamped to the bucket's retention). queues: narrows to one queue (else every live queue). Returns [{name:, points: [{at:, size:, latency:}, …]}, …].



162
163
164
# File 'lib/wurk/web/enterprise.rb', line 162

def queue_history(bucket, window:, queues: nil, now: ::Time.now)
  Wurk::Metrics::Query.queue_history(bucket, window, queues: queues, now: now)
end

.snapshots(limit: Wurk::History::STREAM_DEFAULT_LIMIT) ⇒ Object

Ent §5.3 Historical snapshots from the history:metrics stream, oldest→newest. Returns [{at:, processed:, failures:, …}, …].



168
169
170
# File 'lib/wurk/web/enterprise.rb', line 168

def snapshots(limit: Wurk::History::STREAM_DEFAULT_LIMIT)
  Wurk::History.recent(limit: limit)
end

.top(minutes: 60, class_filter: nil) ⇒ Object

Global top-N rollup. Wraps Query.top_jobs and keeps the wire shape of [[class_name, {p:, f:, ms:}], ...].



147
148
149
# File 'lib/wurk/web/enterprise.rb', line 147

def top(minutes: 60, class_filter: nil)
  Wurk::Metrics::Query.top_jobs(minutes: minutes, class_filter: class_filter)
end