FEATURE: Expose metric for Sidekiq paused status.

FEATURE: Expose metric for Sidekiq paused status.

diff --git a/lib/internal_metric/global.rb b/lib/internal_metric/global.rb
index 6ea6f52..b7c9577 100644
--- a/lib/internal_metric/global.rb
+++ b/lib/internal_metric/global.rb
@@ -15,7 +15,8 @@ module DiscoursePrometheus::InternalMetric
       :active_app_reqs,
       :queued_app_reqs,
       :sidekiq_jobs_enqueued,
-      :sidekiq_processes
+      :sidekiq_processes,
+      :sidekiq_paused
 
     def initialize
       @active_app_reqs = 0
@@ -60,6 +61,7 @@ module DiscoursePrometheus::InternalMetric
       end
 
       @sidekiq_processes = (Sidekiq::ProcessSet.new.size || 0) rescue 0
+      @sidekiq_paused = Sidekiq.paused? ? 1 : 0
     end
 
     private
diff --git a/spec/lib/internal_metric/global_spec.rb b/spec/lib/internal_metric/global_spec.rb
index 32457dd..622e100 100644
--- a/spec/lib/internal_metric/global_spec.rb
+++ b/spec/lib/internal_metric/global_spec.rb
@@ -2,13 +2,23 @@ require 'rails_helper'
 
 module DiscoursePrometheus::InternalMetric
   describe Global do
+    after do
+      $redis.flushall
+    end
+
     it "can collect global metrics" do
       metric = Global.new
       metric.collect
 
       expect(metric.sidekiq_processes).not_to eq(nil)
+      expect(metric.sidekiq_paused).to eq(0)
       expect(metric.postgres_master_available).to eq(1)
       expect(metric.postgres_replica_available).to eq(nil)
+
+      Sidekiq.pause!
+      metric.collect
+
+      expect(metric.sidekiq_paused).to eq(1)
     end
 
     describe 'when a replica has been configured' do

GitHub sha: 291b3ffa

1 Like