DEV: Remove flawed collection of `transient_readonly_mode` global metric

DEV: Remove flawed collection of transient_readonly_mode global metric

The metric should be a per-process metric. However, we don’t seem to be using this anywhere in our code base so there isn’t a point in collecting it.

diff --git a/lib/collector.rb b/lib/collector.rb
index 95e4dae..a3bfaa8 100644
--- a/lib/collector.rb
+++ b/lib/collector.rb
@@ -108,11 +108,6 @@ module ::DiscoursePrometheus
       )
 
       global_metrics << Gauge.new(
-        "transient_readonly_mode",
-        "Indicates whether site is in a transient readonly mode"
-      )
-
-      global_metrics << Gauge.new(
         "redis_master_available",
         "Whether or not we have an active connection to the master Redis",
       )
diff --git a/lib/internal_metric/global.rb b/lib/internal_metric/global.rb
index e2f5e77..98955e3 100644
--- a/lib/internal_metric/global.rb
+++ b/lib/internal_metric/global.rb
@@ -10,7 +10,6 @@ module DiscoursePrometheus::InternalMetric
     STUCK_JOB_MINUTES = 120
 
     attribute :postgres_readonly_mode,
-      :transient_readonly_mode,
       :redis_master_available,
       :redis_slave_available,
       :postgres_master_available,
@@ -76,7 +75,6 @@ module DiscoursePrometheus::InternalMetric
       net_stats = Raindrops::Linux::tcp_listener_stats("0.0.0.0:3000")["0.0.0.0:3000"] unless RbConfig::CONFIG["arch"] =~ /darwin/
 
       @postgres_readonly_mode = primary_site_readonly?
-      @transient_readonly_mode = recently_readonly?
       @redis_master_available = redis_master_running
       @redis_slave_available = redis_slave_running
       @postgres_master_available = postgres_master_running
@@ -168,19 +166,6 @@ module DiscoursePrometheus::InternalMetric
       test_connection&.close
     end
 
-    def recently_readonly?
-      recently_readonly = 0
-
-      RailsMultisite::ConnectionManagement.with_connection('default') do
-        recently_readonly = 1 if Discourse.recently_readonly?
-      end
-
-      recently_readonly
-    rescue
-      # no db
-      0
-    end
-
     def sidekiq_paused_states
       paused = {}
 

GitHub sha: 01cf1b31

1 Like