FIX: correct metrics so they are host not per cluster

FIX: correct metrics so they are host not per cluster

per host metrics are far more powerful, especially once deployed across multiple machines

diff --git a/lib/internal_metric/global.rb b/lib/internal_metric/global.rb
index eee42d1..034f1c6 100644
--- a/lib/internal_metric/global.rb
+++ b/lib/internal_metric/global.rb
@@ -80,14 +80,20 @@ module DiscoursePrometheus::InternalMetric
         stats
       end
 
-      # not correct, should be per machine
-      @sidekiq_workers = Sidekiq::ProcessSet.new.sum { |p| p["concurrency"] }
+      @sidekiq_processes = 0
+      @sidekiq_workers = Sidekiq::ProcessSet.new.sum do |process|
+        if process["hostname"] == Global.hostname
+          @sidekiq_processes += 1
+          process["concurrency"]
+        else
+          0
+        end
+      end
 
       @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
 
       @missing_s3_uploads = missing_uploads("s3")

GitHub sha: e2b144e2

1 Like