diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-05-19 17:03:10 +0200 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-02 19:45:58 +0200 |
commit | 0f4050430d400daffbc5a68b15d79b896bb8a692 (patch) | |
tree | 7140c4edba672350570f53f26effe85ba4ba6289 /app/controllers/health_controller.rb | |
parent | cf932df2348dc3ccd06ca557b68edc60f518c893 (diff) | |
download | gitlab-ce-0f4050430d400daffbc5a68b15d79b896bb8a692.tar.gz |
Split metrics from health controller into metrics controller
Diffstat (limited to 'app/controllers/health_controller.rb')
-rw-r--r-- | app/controllers/health_controller.rb | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/app/controllers/health_controller.rb b/app/controllers/health_controller.rb index 6f8038f6ec3..b646216caa2 100644 --- a/app/controllers/health_controller.rb +++ b/app/controllers/health_controller.rb @@ -22,37 +22,8 @@ class HealthController < ActionController::Base render_check_results(results) end - def metrics - response = health_metrics_text + "\n" - - if Gitlab::Metrics.prometheus_metrics_enabled? - response += Prometheus::Client::Formats::Text.marshal_multiprocess(ENV['prometheus_multiproc_dir']) - end - - render text: response, content_type: 'text/plain; version=0.0.4' - end - private - def health_metrics_text - results = CHECKS.flat_map(&:metrics) - - types = results.map(&:name) - .uniq - .map { |metric_name| "# TYPE #{metric_name} gauge" } - metrics = results.map(&method(:metric_to_prom_line)) - types.concat(metrics).join("\n") - end - - def metric_to_prom_line(metric) - labels = metric.labels&.map { |key, value| "#{key}=\"#{value}\"" }&.join(',') || '' - if labels.empty? - "#{metric.name} #{metric.value}" - else - "#{metric.name}{#{labels}} #{metric.value}" - end - end - def render_check_results(results) flattened = results.flat_map do |name, result| if result.is_a?(Gitlab::HealthChecks::Result) |