From 5f2dc999bd5dbcf9707c7e5a89e2e18ec419bb2d Mon Sep 17 00:00:00 2001 From: Pawel Chojnacki <pawel@chojnacki.ws> Date: Tue, 20 Jun 2017 12:22:56 +0200 Subject: [PATCH] use proper `if defined?` check. --- lib/gitlab/metrics/prometheus.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/gitlab/metrics/prometheus.rb b/lib/gitlab/metrics/prometheus.rb index 25421c0a92f..9d314a56e58 100644 --- a/lib/gitlab/metrics/prometheus.rb +++ b/lib/gitlab/metrics/prometheus.rb @@ -6,12 +6,15 @@ module Gitlab include Gitlab::CurrentSettings def metrics_folder_present? - ENV.has_key?('prometheus_multiproc_dir') && ::Dir.exist?(ENV['prometheus_multiproc_dir']) && + ENV.has_key?('prometheus_multiproc_dir') && + ::Dir.exist?(ENV['prometheus_multiproc_dir']) && ::File.writable?(ENV['prometheus_multiproc_dir']) end def prometheus_metrics_enabled? - @prometheus_metrics_enabled ||= prometheus_metrics_enabled_unmemoized + return @prometheus_metrics_enabled if defined?(@prometheus_metrics_enabled) + + @prometheus_metrics_enabled = prometheus_metrics_enabled_unmemoized end def registry -- GitLab