Commit 99391e80 authored by Aleksei Lipniagov's avatar Aleksei Lipniagov

Move CleanupMultiprocDirService out of config.ru

parent c89d94e5
---
title: Move CleanupMultiprocDirService out of config.ru
merge_request: 53139
author:
type: other
...@@ -22,12 +22,6 @@ def master_process? ...@@ -22,12 +22,6 @@ def master_process?
end end
warmup do |app| warmup do |app|
# The following is necessary to ensure stale Prometheus metrics don't accumulate over time.
# It needs to be done as early as here to ensure metrics files aren't deleted.
# After we hit our app in `warmup`, first metrics and corresponding files already being created,
# for example in `lib/gitlab/metrics/requests_rack_middleware.rb`.
Prometheus::CleanupMultiprocDirService.new.execute if master_process?
client = Rack::MockRequest.new(app) client = Rack::MockRequest.new(app)
client.get('/') client.get('/')
end end
......
...@@ -39,19 +39,24 @@ Sidekiq.configure_server do |config| ...@@ -39,19 +39,24 @@ Sidekiq.configure_server do |config|
end end
if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled? if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled?
Gitlab::Cluster::LifecycleEvents.on_worker_start do # When running Puma in a Single mode, `on_master_start` and `on_worker_start` are the same.
defined?(::Prometheus::Client.reinitialize_on_pid_change) && Prometheus::Client.reinitialize_on_pid_change # Thus, we order these events to run `reinitialize_on_pid_change` with `force: true` first.
Gitlab::Cluster::LifecycleEvents.on_master_start do
# Ensure that stale Prometheus metrics don't accumulate over time
Prometheus::CleanupMultiprocDirService.new.execute
Gitlab::Metrics::Samplers::RubySampler.initialize_instance.start ::Prometheus::Client.reinitialize_on_pid_change(force: true)
Gitlab::Metrics::Samplers::DatabaseSampler.initialize_instance.start
Gitlab::Metrics::Samplers::ThreadsSampler.initialize_instance.start
if Gitlab::Runtime.action_cable? if Gitlab::Runtime.unicorn?
Gitlab::Metrics::Samplers::ActionCableSampler.instance.start Gitlab::Metrics::Samplers::UnicornSampler.instance(Settings.monitoring.unicorn_sampler_interval).start
elsif Gitlab::Runtime.puma?
Gitlab::Metrics::Samplers::PumaSampler.instance.start
end end
if Gitlab.ee? && Gitlab::Runtime.sidekiq? Gitlab::Metrics.gauge(:deployments, 'GitLab Version', {}, :max).set({ version: Gitlab::VERSION }, 1)
Gitlab::Metrics::Samplers::GlobalSearchSampler.instance.start
unless Gitlab::Runtime.sidekiq?
Gitlab::Metrics::RequestsRackMiddleware.initialize_metrics
end end
Gitlab::Ci::Parsers.instrument! Gitlab::Ci::Parsers.instrument!
...@@ -60,19 +65,19 @@ if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled? ...@@ -60,19 +65,19 @@ if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled?
Gitlab::Metrics.error_detected! Gitlab::Metrics.error_detected!
end end
Gitlab::Cluster::LifecycleEvents.on_master_start do Gitlab::Cluster::LifecycleEvents.on_worker_start do
::Prometheus::Client.reinitialize_on_pid_change(force: true) defined?(::Prometheus::Client.reinitialize_on_pid_change) && Prometheus::Client.reinitialize_on_pid_change
if Gitlab::Runtime.unicorn? Gitlab::Metrics::Samplers::RubySampler.initialize_instance.start
Gitlab::Metrics::Samplers::UnicornSampler.instance(Settings.monitoring.unicorn_sampler_interval).start Gitlab::Metrics::Samplers::DatabaseSampler.initialize_instance.start
elsif Gitlab::Runtime.puma? Gitlab::Metrics::Samplers::ThreadsSampler.initialize_instance.start
Gitlab::Metrics::Samplers::PumaSampler.instance.start
end
Gitlab::Metrics.gauge(:deployments, 'GitLab Version', {}, :max).set({ version: Gitlab::VERSION }, 1) if Gitlab::Runtime.action_cable?
Gitlab::Metrics::Samplers::ActionCableSampler.instance.start
end
unless Gitlab::Runtime.sidekiq? if Gitlab.ee? && Gitlab::Runtime.sidekiq?
Gitlab::Metrics::RequestsRackMiddleware.initialize_metrics Gitlab::Metrics::Samplers::GlobalSearchSampler.instance.start
end end
Gitlab::Ci::Parsers.instrument! Gitlab::Ci::Parsers.instrument!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment