FIX: if we fail to connect to redis report exception

FIX: if we fail to connect to redis report exception

This avoids throwing away the entire global metric collection if there is a transient redis failure.

diff --git a/lib/internal_metric/global.rb b/lib/internal_metric/global.rb
index 4702632..0d9c5b7 100644
--- a/lib/internal_metric/global.rb
+++ b/lib/internal_metric/global.rb
@@ -159,8 +159,12 @@ module DiscoursePrometheus::InternalMetric
     def sidekiq_paused_states
       paused = {}
 
-      RailsMultisite::ConnectionManagement.each_connection do |db|
-        paused[{ db: db }] = Sidekiq.paused? ? 1 : nil
+      begin
+        RailsMultisite::ConnectionManagement.each_connection do |db|
+          paused[{ db: db }] = Sidekiq.paused? ? 1 : nil
+        end
+      rescue => e
+        Discourse.warn_exception(e, message: "Failed to connect to redis to collect paused status")
       end
 
       paused

GitHub sha: 133390a4

1 Like