https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
36 lines
1,012 B
Diff
36 lines
1,012 B
Diff
diff --git a/lib/internal_metric/global.rb b/lib/internal_metric/global.rb
|
|
index 682571b..7bdd431 100644
|
|
--- a/lib/internal_metric/global.rb
|
|
+++ b/lib/internal_metric/global.rb
|
|
@@ -30,30 +30,7 @@ module DiscoursePrometheus::InternalMetric
|
|
@active_app_reqs = 0
|
|
@queued_app_reqs = 0
|
|
@fault_logged = {}
|
|
-
|
|
- begin
|
|
- @@version = nil
|
|
-
|
|
- out, error, status = Open3.capture3('git rev-parse HEAD')
|
|
-
|
|
- if status.success?
|
|
- @@version ||= out.chomp
|
|
- else
|
|
- raise error
|
|
- end
|
|
- rescue => e
|
|
- if defined?(::Discourse)
|
|
- Discourse.warn_exception(e, message: "Failed to calculate discourse_version_info metric")
|
|
- else
|
|
- STDERR.puts "Failed to calculate discourse_version_info metric: #{e}\n#{e.backtrace.join("\n")}"
|
|
- end
|
|
-
|
|
- @@retries ||= 10
|
|
- @@retries -= 1
|
|
- if @@retries < 0
|
|
- @@version = -1
|
|
- end
|
|
- end
|
|
+ @@version = -1
|
|
end
|
|
|
|
def collect
|