FEATURE: track git version number

FEATURE: track git version number

This allows us to alert if there is inconsistency around versions

diff --git a/lib/collector.rb b/lib/collector.rb
index f921711..a246c4e 100644
--- a/lib/collector.rb
+++ b/lib/collector.rb
@@ -167,6 +167,11 @@ module ::DiscoursePrometheus
         "Number of missing post uploads"
       )
 
+      global_metrics << Gauge.new(
+        "version",
+        "Revision number of discourse starting from HEAD"
+      )
+
       @global_metrics = global_metrics
     end
 
diff --git a/lib/internal_metric/global.rb b/lib/internal_metric/global.rb
index 3e4e0bd..3fd320b 100644
--- a/lib/internal_metric/global.rb
+++ b/lib/internal_metric/global.rb
@@ -18,13 +18,18 @@ module DiscoursePrometheus::InternalMetric
       :sidekiq_processes,
       :sidekiq_paused,
       :missing_post_uploads,
-      :missing_s3_uploads
+      :missing_s3_uploads,
+      :version
 
     def initialize
       @active_app_reqs = 0
       @queued_app_reqs = 0
-
       @fault_logged = {}
+      begin
+        @version = `git rev-list --count HEAD`.to_i
+      rescue
+        @version = 0
+      end
     end
 
     def collect

GitHub sha: ad0223b7

1 Like