Commit ab108cd3 authored by Stan Hu's avatar Stan Hu

Merge branch 'sh-fix-order-dependent-prometheus-spec' into 'master'

Fix order-dependent Prometheus metrics specs

Closes #196048

See merge request gitlab-org/gitlab!22690
parents 44739602 e500cc49
...@@ -62,10 +62,18 @@ module Gitlab ...@@ -62,10 +62,18 @@ module Gitlab
end end
def error_detected! def error_detected!
set_error!(true)
end
def clear_errors!
set_error!(false)
end
def set_error!(status)
clear_memoization(:prometheus_metrics_enabled) clear_memoization(:prometheus_metrics_enabled)
PROVIDER_MUTEX.synchronize do PROVIDER_MUTEX.synchronize do
@error = true @error = status
end end
end end
......
...@@ -6,6 +6,10 @@ describe Gitlab::Metrics::Prometheus, :prometheus do ...@@ -6,6 +6,10 @@ describe Gitlab::Metrics::Prometheus, :prometheus do
let(:all_metrics) { Gitlab::Metrics } let(:all_metrics) { Gitlab::Metrics }
let(:registry) { all_metrics.registry } let(:registry) { all_metrics.registry }
after do
all_metrics.clear_errors!
end
describe '#reset_registry!' do describe '#reset_registry!' do
it 'clears existing metrics' do it 'clears existing metrics' do
registry.counter(:test, 'test metric') registry.counter(:test, 'test metric')
......
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