Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2017-05-23 16:18:03 +0300
committerPawel Chojnacki <pawel@chojnacki.ws>2017-06-02 20:45:58 +0300
commit466beeb31f9ede870f1e6f4e85642a375663eaf2 (patch)
tree99154ed2f945bf184963bcac27f24e899be85ecb /app
parent62fe37e3f8e8ccee90a748324e1b40a54f4c55c8 (diff)
Use interpolation instead of concatenation
Diffstat (limited to 'app')
-rw-r--r--app/controllers/metrics_controller.rb8
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