2017-07-19 04:54:39 -04:00
|
|
|
require 'prometheus/client'
|
2017-08-29 09:45:19 -04:00
|
|
|
require 'prometheus/client/support/unicorn'
|
2017-07-19 04:54:39 -04:00
|
|
|
|
|
|
|
Prometheus::Client.configure do |config|
|
|
|
|
config.logger = Rails.logger
|
|
|
|
|
|
|
|
config.initial_mmap_file_size = 4 * 1024
|
|
|
|
config.multiprocess_files_dir = ENV['prometheus_multiproc_dir']
|
|
|
|
|
2017-07-25 08:19:09 -04:00
|
|
|
if Rails.env.development? || Rails.env.test?
|
2017-07-19 04:54:39 -04:00
|
|
|
config.multiprocess_files_dir ||= Rails.root.join('tmp/prometheus_multiproc_dir')
|
|
|
|
end
|
2017-08-29 09:45:19 -04:00
|
|
|
|
2017-12-07 11:47:23 -05:00
|
|
|
config.pid_provider = Prometheus::Client::Support::Unicorn.method(:worker_pid_provider)
|
2017-07-19 04:54:39 -04:00
|
|
|
end
|
2017-08-07 13:13:02 -04:00
|
|
|
|
2017-11-22 18:26:50 -05:00
|
|
|
Gitlab::Application.configure do |config|
|
|
|
|
# 0 should be Sentry to catch errors in this middleware
|
|
|
|
config.middleware.insert(1, Gitlab::Metrics::RequestsRackMiddleware)
|
|
|
|
end
|
|
|
|
|
2017-08-07 13:13:02 -04:00
|
|
|
Sidekiq.configure_server do |config|
|
|
|
|
config.on(:startup) do
|
|
|
|
Gitlab::Metrics::SidekiqMetricsExporter.instance.start
|
|
|
|
end
|
|
|
|
end
|
2017-08-10 10:18:37 -04:00
|
|
|
|
2017-09-05 19:26:31 -04:00
|
|
|
if Gitlab::Metrics.prometheus_metrics_enabled?
|
2017-11-02 16:23:23 -04:00
|
|
|
unless Sidekiq.server?
|
|
|
|
Gitlab::Metrics::Samplers::UnicornSampler.initialize_instance(Settings.monitoring.unicorn_sampler_interval).start
|
|
|
|
end
|
|
|
|
|
2017-09-05 19:26:31 -04:00
|
|
|
Gitlab::Metrics::Samplers::RubySampler.initialize_instance(Settings.monitoring.ruby_sampler_interval).start
|
|
|
|
end
|