Skip to content
Permalink
Browse files

FIX: count stuck workers per host

  • Loading branch information
SamSaffron committed Feb 14, 2020
1 parent 20f68f7 commit ace70d36c41dcf755e930b8e60a372b9817965cb
Showing with 15 additions and 1 deletion.
  1. +15 −1 lib/internal_metric/global.rb
@@ -5,6 +5,16 @@

module DiscoursePrometheus::InternalMetric
class Global < Base

def self.hostname
@hostname ||=
begin
Discourse::Utils.execute_command("hostname").strip
rescue
"Unknown"
end
end

STUCK_JOB_MINUTES = 60

attribute :postgres_readonly_mode,
@@ -70,8 +80,12 @@ def collect
stats
end

# not correct, should be per machine
@sidekiq_workers = Sidekiq::ProcessSet.new.sum { |p| p["concurrency"] }
@sidekiq_stuck_workers = Sidekiq::Workers.new.filter { |_, _, w| Time.at(w["run_at"]) < (Time.now - 60 * STUCK_JOB_MINUTES) }.count

@sidekiq_stuck_workers = Sidekiq::Workers.new.filter do |queue, _, w|
queue.start_with?(Global.hostname) && Time.at(w["run_at"]) < (Time.now - 60 * STUCK_JOB_MINUTES)
end.count

@sidekiq_processes = (Sidekiq::ProcessSet.new.size || 0) rescue 0
@sidekiq_paused = sidekiq_paused_states

0 comments on commit ace70d3

Please sign in to comment.
You can’t perform that action at this time.