diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2019-07-02 20:05:56 +0300 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2019-07-02 20:05:56 +0300 |
commit | 3c883759c6ea9c1c60e69fd3e65fbf56b9e7af30 (patch) | |
tree | 08ea719ad67f532e17fd05dbc360b3a775508a8b | |
parent | 5fb1de48ccbd5f637b6a8d2d9889a480d7d359a2 (diff) |
Start UnicornSampler in master process
Using `on_master_start` assures that the sampler is started in
master process and not in worker processes.
-rw-r--r-- | changelogs/unreleased/unicorn-sampler-fix.yml | 5 | ||||
-rw-r--r-- | config/initializers/7_prometheus_metrics.rb | 10 |
2 files changed, 9 insertions, 6 deletions
diff --git a/changelogs/unreleased/unicorn-sampler-fix.yml b/changelogs/unreleased/unicorn-sampler-fix.yml new file mode 100644 index 00000000000..3f0e509f15f --- /dev/null +++ b/changelogs/unreleased/unicorn-sampler-fix.yml @@ -0,0 +1,5 @@ +--- +title: Make sure UnicornSampler is started only in master process. +merge_request: 30215 +author: +type: fixed diff --git a/config/initializers/7_prometheus_metrics.rb b/config/initializers/7_prometheus_metrics.rb index 54cdefc2a10..5db72141fcd 100644 --- a/config/initializers/7_prometheus_metrics.rb +++ b/config/initializers/7_prometheus_metrics.rb @@ -29,15 +29,13 @@ if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled? Gitlab::Cluster::LifecycleEvents.on_worker_start do defined?(::Prometheus::Client.reinitialize_on_pid_change) && Prometheus::Client.reinitialize_on_pid_change - if defined?(::Unicorn) - Gitlab::Metrics::Samplers::UnicornSampler.initialize_instance(Settings.monitoring.unicorn_sampler_interval).start - end - Gitlab::Metrics::Samplers::RubySampler.initialize_instance(Settings.monitoring.ruby_sampler_interval).start end - if defined?(::Puma) - Gitlab::Cluster::LifecycleEvents.on_master_start do + Gitlab::Cluster::LifecycleEvents.on_master_start do + if defined?(::Unicorn) + Gitlab::Metrics::Samplers::UnicornSampler.initialize_instance(Settings.monitoring.unicorn_sampler_interval).start + elsif defined?(::Puma) Gitlab::Metrics::Samplers::PumaSampler.initialize_instance(Settings.monitoring.puma_sampler_interval).start end end |