diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2019-06-12 13:33:34 +0300 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2019-06-12 13:33:34 +0300 |
commit | 13364c00d57ce3150a50c23ea3eb0e6af4271d92 (patch) | |
tree | 7f31f9e3fb368f7f37c7fa205123c4d550e56df9 /spec/lib/gitlab/cluster | |
parent | d3a7bdda986949ca76df3c4932ee8c973437a743 (diff) |
Monitor only final states
There is no reason to monitor transition states so we ignore
ready and active states. We can get ratio of completed vs failed
requests from final states.
Diffstat (limited to 'spec/lib/gitlab/cluster')
-rw-r--r-- | spec/lib/gitlab/cluster/rack_timeout_observer_spec.rb | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/spec/lib/gitlab/cluster/rack_timeout_observer_spec.rb b/spec/lib/gitlab/cluster/rack_timeout_observer_spec.rb index 2adb1d7cc71..68e5435450c 100644 --- a/spec/lib/gitlab/cluster/rack_timeout_observer_spec.rb +++ b/spec/lib/gitlab/cluster/rack_timeout_observer_spec.rb @@ -25,7 +25,7 @@ describe Gitlab::Cluster::RackTimeoutObserver do subject { described_class.new } - it 'increments timeout counter' do + it 'increments counter' do expect(counter) .to receive(:increment) .with({ controller: 'foo', action: 'bar', route: nil, state: :timed_out }) @@ -45,7 +45,7 @@ describe Gitlab::Cluster::RackTimeoutObserver do subject { described_class.new } - it 'increments timeout counter' do + it 'increments counter' do allow(endpoint).to receive_message_chain('route.pattern.origin') { 'foobar' } expect(counter) .to receive(:increment) @@ -54,5 +54,24 @@ describe Gitlab::Cluster::RackTimeoutObserver do subject.callback.call(env) end end + + context 'when request is being processed' do + let(:endpoint) { double } + let(:env) do + { + ::Rack::Timeout::ENV_INFO_KEY => double(state: :active), + Grape::Env::API_ENDPOINT => endpoint + } + end + + subject { described_class.new } + + it 'does not increment counter' do + allow(endpoint).to receive_message_chain('route.pattern.origin') { 'foobar' } + expect(counter).not_to receive(:increment) + + subject.callback.call(env) + end + end end end |