diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-09-07 22:36:51 +0300 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-11-02 20:11:44 +0300 |
commit | 95a23d246c9a4884b4622d9310afb2ada9552a6d (patch) | |
tree | 75c68bbbdec98af3c087bad6bcf1236e6044bd50 /spec/lib/gitlab/middleware | |
parent | 44eedb22bcb799d1c8dd7b30114f3c24ad8649a4 (diff) |
Convert rails_queue_duration to metric_rails_queue_duration_seconds
Diffstat (limited to 'spec/lib/gitlab/middleware')
-rw-r--r-- | spec/lib/gitlab/middleware/rails_queue_duration_spec.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/spec/lib/gitlab/middleware/rails_queue_duration_spec.rb b/spec/lib/gitlab/middleware/rails_queue_duration_spec.rb index 88107536c9e..b14c4477590 100644 --- a/spec/lib/gitlab/middleware/rails_queue_duration_spec.rb +++ b/spec/lib/gitlab/middleware/rails_queue_duration_spec.rb @@ -4,7 +4,7 @@ describe Gitlab::Middleware::RailsQueueDuration do let(:app) { double(:app) } let(:middleware) { described_class.new(app) } let(:env) { {} } - let(:transaction) { double(:transaction) } + let(:transaction) { Gitlab::Metrics::Transaction.new(env) } before do expect(app).to receive(:call).with(env).and_return('yay') @@ -30,6 +30,16 @@ describe Gitlab::Middleware::RailsQueueDuration do expect(transaction).to receive(:set).with(:rails_queue_duration, an_instance_of(Float)) expect(middleware.call(env)).to eq('yay') end + + it 'observes rails queue duration metrics and calls the app when the header is present' do + env['HTTP_GITLAB_WORKHORSE_PROXY_START'] = '2000000000' + + expect(described_class.metric_rails_queue_duration_seconds).to receive(:observe).with(transaction.labels, 1) + + Timecop.freeze(Time.at(3)) do + expect(middleware.call(env)).to eq('yay') + end + end end end end |