diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-05-29 15:19:43 +0300 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-02 20:45:58 +0300 |
commit | c134a72cdb7e6de8b70dc60de99cf4edc68a9227 (patch) | |
tree | 0082ba4d422cc53eea223583bca9c98cbc823c96 /app/services | |
parent | 770f07cd5c68075bb261f4b6139c92b2ac9309c0 (diff) |
Move Prometheus presentation logic to PrometheusText
+ Use NullMetrics to mock metrics when unused
+ Use method_missing in NullMetrics mocking
+ Update prometheus gem to version that correctly uses transitive dependencies
+ Ensure correct folders are used in Multiprocess prometheus client tests.
+ rename Sessions controller's metric
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/metrics_service.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/app/services/metrics_service.rb b/app/services/metrics_service.rb index 350c3639e92..0faa86a228b 100644 --- a/app/services/metrics_service.rb +++ b/app/services/metrics_service.rb @@ -12,18 +12,23 @@ class MetricsService end def health_metrics_text - results = CHECKS.flat_map(&:metrics) + metrics = CHECKS.flat_map(&:metrics) - types = results.map(&:name).uniq.map { |metric_name| "# TYPE #{metric_name} gauge" } - metrics = results.map(&method(:metric_to_prom_line)) + formatter.marshal(metrics) + end - types.concat(metrics).join("\n") + def metrics_text + "#{health_metrics_text}\n#{prometheus_metrics_text}" end private + def formatter + @formatter ||= PrometheusText.new + end + def multiprocess_metrics_path - Rails.root.join(ENV['prometheus_multiproc_dir']) + @multiprocess_metrics_path ||= Rails.root.join(ENV['prometheus_multiproc_dir']) end def metric_to_prom_line(metric) |