FIX: reset global metrics when collecting

FIX: reset global metrics when collecting

This ensures all leftover labels are cleaned up. Very important in a multisite situation where we are decomissioning and old labels no longer make sense.

diff --git a/lib/collector.rb b/lib/collector.rb
index ade6f73..99278b7 100644
--- a/lib/collector.rb
+++ b/lib/collector.rb
@@ -83,6 +83,9 @@ module ::DiscoursePrometheus
       ensure_global_metrics
       @global_metrics.each do |gauge|
         values = metric.send(gauge.name)
+        # global metrics "reset" each time they are called
+        # this will delete labels we don't need anymore
+        gauge.reset!
 
         if values.is_a?(Hash)
           values.each do |labels, value|
diff --git a/prometheus_exporter_version b/prometheus_exporter_version
index 1f77169..5745cc7 100644
--- a/prometheus_exporter_version
+++ b/prometheus_exporter_version
@@ -1 +1 @@
-0.4.13
+0.4.16

GitHub sha: 870ab7b0

1 Like