diff options
author | Aleksei Lipniagov <alipniagov@gitlab.com> | 2019-07-02 10:36:33 +0300 |
---|---|---|
committer | Aleksei Lipniagov <alipniagov@gitlab.com> | 2019-07-02 18:42:01 +0300 |
commit | 57ae2f7e2d56a38140ae66915885567d361e240a (patch) | |
tree | 50cc483221f0846dbe189449be50dd90c5a024f7 | |
parent | 833c4b81a582c5ea067e1302ac80b4417c647d8c (diff) | |
download | gitlab-ce-57ae2f7e2d56a38140ae66915885567d361e240a.tar.gz |
Use separate Prometheus metrics dirs in dev/test63869-store-prometheus-metrics-in-separate-dirs-in-test-and-prod
Store Sidekiq and Web server metrics from Prometheus in separate
directories in `development` and `test` environments.
-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 54cdefc2a10..d70d83b24d9 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 |