Commit 466beeb3 authored by Pawel Chojnacki's avatar Pawel Chojnacki

Use interpolation instead of concatenation

parent 62fe37e3
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment