Class: SolidQueueGuard::Checks::Runtime::FailedJobsCheck

Inherits:
Base
  • Object
show all
Defined in:
lib/solid_queue_guard/checks/runtime/failed_jobs_check.rb

Constant Summary collapse

WINDOW =
1.hour

Instance Method Summary collapse

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/solid_queue_guard/checks/runtime/failed_jobs_check.rb', line 9

def call
  with_queue_database do
    count = SolidQueue::FailedExecution.where(created_at: WINDOW.ago..).count
    threshold = config.check_setting(:failed_jobs, :threshold, config.failed_jobs_threshold)

    if count > threshold
      warn(
        check_id,
        "#{count} failed job(s) in the last hour (threshold: #{threshold})",
        suggestion: 'Review failed jobs in Mission Control or solid_queue_failed_executions',
        metadata: { failed_jobs_last_hour: count }
      )
    else
      pass(check_id, "#{count} failed job(s) in the last hour")
    end
  end
end