2024-03-20 08:52:25 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ProblemCheck::SidekiqCheck < ProblemCheck
|
|
|
|
self.priority = "low"
|
|
|
|
|
|
|
|
def call
|
2024-05-23 09:29:08 +08:00
|
|
|
if jobs_in_queue? && !jobs_performed_recently?
|
|
|
|
return problem(override_key: "dashboard.problem.sidekiq")
|
|
|
|
end
|
|
|
|
|
|
|
|
if massive_queue?
|
|
|
|
return(
|
|
|
|
problem(
|
|
|
|
override_key: "dashboard.problem.queue_size",
|
|
|
|
override_data: {
|
|
|
|
queue_size: Jobs.queued,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
end
|
2024-03-20 08:52:25 +08:00
|
|
|
|
|
|
|
no_problem
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def massive_queue?
|
|
|
|
Jobs.queued >= 100_000
|
|
|
|
end
|
|
|
|
|
|
|
|
def jobs_in_queue?
|
|
|
|
Jobs.queued > 0
|
|
|
|
end
|
|
|
|
|
|
|
|
def jobs_performed_recently?
|
|
|
|
Jobs.last_job_performed_at.present? && Jobs.last_job_performed_at > 2.minutes.ago
|
|
|
|
end
|
|
|
|
end
|