summaryrefslogtreecommitdiff
path: root/app/controllers/metrics_controller.rb
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2017-05-23 14:55:31 +0200
committerPawel Chojnacki <pawel@chojnacki.ws>2017-06-02 19:45:58 +0200
commit62fe37e3f8e8ccee90a748324e1b40a54f4c55c8 (patch)
tree414b83e3a4a3252cb18566ab543c94a7f3497c73 /app/controllers/metrics_controller.rb
parent21561f3434021ad35d45c449f489802fd1dced67 (diff)
downloadgitlab-ce-62fe37e3f8e8ccee90a748324e1b40a54f4c55c8.tar.gz
move check if metrics are enabled to before action
Diffstat (limited to 'app/controllers/metrics_controller.rb')
-rw-r--r--app/controllers/metrics_controller.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/controllers/metrics_controller.rb b/app/controllers/metrics_controller.rb
index 4c1d04c1262..b062496eb2a 100644
--- a/app/controllers/metrics_controller.rb
+++ b/app/controllers/metrics_controller.rb
@@ -3,6 +3,7 @@ require 'prometheus/client/formats/text'
class MetricsController < ActionController::Base
protect_from_forgery with: :exception
include RequiresHealthToken
+ before_action :ensure_prometheus_metrics_are_enabled
CHECKS = [
Gitlab::HealthChecks::DbCheck,
@@ -10,9 +11,8 @@ class MetricsController < ActionController::Base
Gitlab::HealthChecks::FsShardsCheck
].freeze
- def metrics
- return render_404 unless Gitlab::Metrics.prometheus_metrics_enabled?
+ def metrics
metrics_text = Prometheus::Client::Formats::Text.marshal_multiprocess(multiprocess_metrics_path)
response = health_metrics_text + "\n" + metrics_text
@@ -21,6 +21,10 @@ class MetricsController < ActionController::Base
private
+ def ensure_prometheus_metrics_are_enabled
+ return render_404 unless Gitlab::Metrics.prometheus_metrics_enabled?
+ end
+
def multiprocess_metrics_path
Rails.root.join(ENV['prometheus_multiproc_dir'])
end