diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-07-02 20:52:12 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-07-02 20:52:12 +0000 |
commit | a0c98f70708a2bb1d867cbac6310cd60307fee04 (patch) | |
tree | 3681b45ee2e57d4a2e14930680d664dc56615c3f | |
parent | 3814285bb2ff6d9725a46a918e689ff3d154ce04 (diff) | |
parent | 57ae2f7e2d56a38140ae66915885567d361e240a (diff) | |
download | gitlab-ce-a0c98f70708a2bb1d867cbac6310cd60307fee04.tar.gz |
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
-rw-r--r-- | config/initializers/7_prometheus_metrics.rb | 20 | ||||
-rw-r--r-- | tmp/prometheus_multiproc_dir/puma/.gitkeep | 0 | ||||
-rw-r--r-- | tmp/prometheus_multiproc_dir/sidekiq/.gitkeep | 0 | ||||
-rw-r--r-- | tmp/prometheus_multiproc_dir/unicorn/.gitkeep | 0 |
4 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 diff --git a/tmp/prometheus_multiproc_dir/puma/.gitkeep b/tmp/prometheus_multiproc_dir/puma/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/tmp/prometheus_multiproc_dir/puma/.gitkeep diff --git a/tmp/prometheus_multiproc_dir/sidekiq/.gitkeep b/tmp/prometheus_multiproc_dir/sidekiq/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/tmp/prometheus_multiproc_dir/sidekiq/.gitkeep diff --git a/tmp/prometheus_multiproc_dir/unicorn/.gitkeep b/tmp/prometheus_multiproc_dir/unicorn/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/tmp/prometheus_multiproc_dir/unicorn/.gitkeep |