diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-12-07 21:49:44 +0300 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-12-12 20:38:28 +0300 |
commit | 53dc9e83c34b2a0ee2651046de031566f5b925d2 (patch) | |
tree | 68dc8aeacf6b26a289069b2c2e7e807b6e680f75 /spec | |
parent | ad1c186ed386afab578668ccdc21cb02354c81bc (diff) |
Cache feature check for 5 minutes for MethodCall instrumentation toggle
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/metrics/method_call_spec.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/lib/gitlab/metrics/method_call_spec.rb b/spec/lib/gitlab/metrics/method_call_spec.rb index 5341addf911..df4c5167497 100644 --- a/spec/lib/gitlab/metrics/method_call_spec.rb +++ b/spec/lib/gitlab/metrics/method_call_spec.rb @@ -23,6 +23,17 @@ describe Gitlab::Metrics::MethodCall do Feature.get(:prometheus_metrics_method_instrumentation).enable end + it 'feature check is cached for 5 minutes' do + allow(Feature.get(:prometheus_metrics_method_instrumentation)).to receive(:enabled?).and_call_original + allow(Rails.cache).to receive(:fetch).and_call_original + + method_call.measure { 'foo' } + method_call.measure { 'foo' } + + expect(Feature.get(:prometheus_metrics_method_instrumentation)).to have_received(:enabled?).twice + expect(Rails.cache).to have_received(:fetch).with(:prometheus_metrics_method_instrumentation_enabled, expires_in: 5.minutes).twice + end + it 'observes the performance of the supplied block' do expect(described_class.call_duration_histogram) .to receive(:observe) |