Class: Delayed::Monitor

Inherits:
Object
  • Object
show all
Includes:
Runnable
Defined in:
lib/delayed/monitor.rb

Constant Summary collapse

METRICS =
%w(
  count
  future_count
  locked_count
  erroring_count
  failed_count
  max_lock_age
  max_age
  working_count
  workable_count
  alert_age_percent
).freeze

Instance Method Summary collapse

Methods included from Runnable

#start

Constructor Details

#initializeMonitor

Returns a new instance of Monitor.



20
21
22
23
# File 'lib/delayed/monitor.rb', line 20

def initialize
  @jobs = Job.group(priority_case_statement).group(:queue)
  @jobs = @jobs.where(queue: Worker.queues) if Worker.queues.any?
end

Instance Method Details

#run!Object



25
26
27
28
29
30
# File 'lib/delayed/monitor.rb', line 25

def run!
  ActiveSupport::Notifications.instrument('delayed.monitor.run', default_tags) do
    METRICS.each { |metric| emit_metric!(metric) }
  end
  interruptable_sleep(sleep_delay)
end