debian-mirror-gitlab/app/services/metrics_service.rb

36 lines
824 B
Ruby
Raw Normal View History

2017-09-10 17:25:29 +05:30
require 'prometheus/client/formats/text'
class MetricsService
CHECKS = [
Gitlab::HealthChecks::DbCheck,
Gitlab::HealthChecks::Redis::RedisCheck,
Gitlab::HealthChecks::Redis::CacheCheck,
Gitlab::HealthChecks::Redis::QueuesCheck,
2018-03-17 18:26:18 +05:30
Gitlab::HealthChecks::Redis::SharedStateCheck
2017-09-10 17:25:29 +05:30
].freeze
def prometheus_metrics_text
Prometheus::Client::Formats::Text.marshal_multiprocess(multiprocess_metrics_path)
end
def health_metrics_text
metrics = CHECKS.flat_map(&:metrics)
formatter.marshal(metrics)
end
def metrics_text
2018-03-17 18:26:18 +05:30
prometheus_metrics_text.concat(health_metrics_text)
2017-09-10 17:25:29 +05:30
end
private
def formatter
@formatter ||= Gitlab::HealthChecks::PrometheusTextFormat.new
end
def multiprocess_metrics_path
::Prometheus::Client.configuration.multiprocess_files_dir
end
end