diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-07-02 23:52:12 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-07-02 23:52:12 +0300 |
commit | a0c98f70708a2bb1d867cbac6310cd60307fee04 (patch) | |
tree | 3681b45ee2e57d4a2e14930680d664dc56615c3f /config | |
parent | 3814285bb2ff6d9725a46a918e689ff3d154ce04 (diff) | |
parent | 57ae2f7e2d56a38140ae66915885567d361e240a (diff) |
Merge branch '63869-store-prometheus-metrics-in-separate-dirs-in-test-and-prod' into 'master'
Use separate Prometheus metrics dirs in dev/test
Closes #63869
See merge request gitlab-org/gitlab-ce!30253
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/7_prometheus_metrics.rb | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/config/initializers/7_prometheus_metrics.rb b/config/initializers/7_prometheus_metrics.rb index 5db72141fcd..741c8ef1ca0 100644 --- a/config/initializers/7_prometheus_metrics.rb +++ b/config/initializers/7_prometheus_metrics.rb @@ -1,15 +1,27 @@ require 'prometheus/client' require 'prometheus/client/support/unicorn' +# Keep separate directories for separate processes +def prometheus_default_multiproc_dir + return unless Rails.env.development? || Rails.env.test? + + if Sidekiq.server? + Rails.root.join('tmp/prometheus_multiproc_dir/sidekiq') + elsif defined?(Unicorn::Worker) + Rails.root.join('tmp/prometheus_multiproc_dir/unicorn') + elsif defined?(::Puma) + Rails.root.join('tmp/prometheus_multiproc_dir/puma') + else + Rails.root.join('tmp/prometheus_multiproc_dir') + end +end + Prometheus::Client.configure do |config| config.logger = Rails.logger config.initial_mmap_file_size = 4 * 1024 - config.multiprocess_files_dir = ENV['prometheus_multiproc_dir'] - if Rails.env.development? || Rails.env.test? - config.multiprocess_files_dir ||= Rails.root.join('tmp/prometheus_multiproc_dir') - end + config.multiprocess_files_dir = ENV['prometheus_multiproc_dir'] || prometheus_default_multiproc_dir config.pid_provider = Prometheus::Client::Support::Unicorn.method(:worker_pid_provider) end |