summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAleksei Lipniagov <alipniagov@gitlab.com>2019-08-19 12:52:07 +0000
committerKamil TrzciƄski <ayufan@ayufan.eu>2019-08-19 12:52:07 +0000
commitdcfaf49550866a291c316f2901e4274d587e7d37 (patch)
treeb6e6e436383ad699d85720542463ebe63098bf9d /lib
parent1d604d490960102ec9c6692a304015cd344319cd (diff)
downloadgitlab-ce-dcfaf49550866a291c316f2901e4274d587e7d37.tar.gz
Clean Sidekiq metrics from multiproc dir on start
After moving the multiproc dir cleanup into `config.ru`:`warmup`, we stopped cleaning Sidekiq metrics dir which is not correct. This MR intended to fix that. More details: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/31668
Diffstat (limited to 'lib')
-rw-r--r--lib/prometheus/cleanup_multiproc_dir_service.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/prometheus/cleanup_multiproc_dir_service.rb b/lib/prometheus/cleanup_multiproc_dir_service.rb
new file mode 100644
index 00000000000..6418b4de166
--- /dev/null
+++ b/lib/prometheus/cleanup_multiproc_dir_service.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module Prometheus
+ class CleanupMultiprocDirService
+ include Gitlab::Utils::StrongMemoize
+
+ def execute
+ FileUtils.rm_rf(old_metrics) if old_metrics
+ end
+
+ private
+
+ def old_metrics
+ strong_memoize(:old_metrics) do
+ Dir[File.join(multiprocess_files_dir, '*.db')] if multiprocess_files_dir
+ end
+ end
+
+ def multiprocess_files_dir
+ ::Prometheus::Client.configuration.multiprocess_files_dir
+ end
+ end
+end