diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-05-23 15:18:03 +0200 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-02 19:45:58 +0200 |
commit | 466beeb31f9ede870f1e6f4e85642a375663eaf2 (patch) | |
tree | 99154ed2f945bf184963bcac27f24e899be85ecb /app/controllers/metrics_controller.rb | |
parent | 62fe37e3f8e8ccee90a748324e1b40a54f4c55c8 (diff) | |
download | gitlab-ce-466beeb31f9ede870f1e6f4e85642a375663eaf2.tar.gz |
Use interpolation instead of concatenation
Diffstat (limited to 'app/controllers/metrics_controller.rb')
-rw-r--r-- | app/controllers/metrics_controller.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/app/controllers/metrics_controller.rb b/app/controllers/metrics_controller.rb index b062496eb2a..8b99de06d85 100644 --- a/app/controllers/metrics_controller.rb +++ b/app/controllers/metrics_controller.rb @@ -14,7 +14,7 @@ class MetricsController < ActionController::Base def metrics metrics_text = Prometheus::Client::Formats::Text.marshal_multiprocess(multiprocess_metrics_path) - response = health_metrics_text + "\n" + metrics_text + response = "#{health_metrics_text}\n#{metrics_text}" render text: response, content_type: 'text/plain; version=0.0.4' end @@ -32,15 +32,15 @@ class MetricsController < ActionController::Base def health_metrics_text results = CHECKS.flat_map(&:metrics) - types = results.map(&:name) - .uniq - .map { |metric_name| "# TYPE #{metric_name} gauge" } + 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 |