diff options
author | Stan Hu <stanhu@gmail.com> | 2018-05-08 22:29:30 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-05-09 14:33:42 -0700 |
commit | 204af2e1019e661fddc451ad0cfb982453d4085b (patch) | |
tree | 3b6484d2eba16771b96a41f8f2e994678f278ecb /lib | |
parent | 5b0e96d09a7b6309384ef4c300c56872adba0626 (diff) | |
download | gitlab-ce-204af2e1019e661fddc451ad0cfb982453d4085b.tar.gz |
Support resetting of Prometheus metrics between test runs
Adding the :prometheus tag to an rspec test will clear out
memory-mapped files and reset the registry.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/39968
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/metrics/prometheus.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/gitlab/metrics/prometheus.rb b/lib/gitlab/metrics/prometheus.rb index d12ba0ec176..d41a855bff1 100644 --- a/lib/gitlab/metrics/prometheus.rb +++ b/lib/gitlab/metrics/prometheus.rb @@ -25,6 +25,14 @@ module Gitlab end end + def reset_registry! + clear_memoization(:registry) + + REGISTRY_MUTEX.synchronize do + ::Prometheus::Client.reset! + end + end + def registry strong_memoize(:registry) do REGISTRY_MUTEX.synchronize do |