diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-05-26 20:05:26 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-05-26 20:05:26 +0300 |
commit | 9bdfc98242f6fa039b73f47e6105faded1027eb1 (patch) | |
tree | 32a6f3b1b8ace2f45c33865b4542dcdf78c69268 /spec/lib | |
parent | d4d0fdb4799d3b1653e9f1a673b4dc6b8c1ac2f8 (diff) | |
parent | 5771114f9b5dba9c17b273a5dec0ef6900f6da9d (diff) |
Merge branch 'measure-proxy-timing' into 'master'
Measure proxy flight time
See merge request !4278
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/middleware/rails_queue_duration_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/lib/gitlab/middleware/rails_queue_duration_spec.rb b/spec/lib/gitlab/middleware/rails_queue_duration_spec.rb new file mode 100644 index 00000000000..fd6f684db0c --- /dev/null +++ b/spec/lib/gitlab/middleware/rails_queue_duration_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +describe Gitlab::Middleware::RailsQueueDuration do + let(:app) { double(:app) } + let(:middleware) { described_class.new(app) } + let(:env) { {} } + let(:transaction) { double(:transaction) } + + before { expect(app).to receive(:call).with(env).and_return('yay') } + + describe '#call' do + it 'calls the app when metrics are disabled' do + expect(Gitlab::Metrics).to receive(:current_transaction).and_return(nil) + expect(middleware.call(env)).to eq('yay') + end + + context 'when metrics are enabled' do + before { allow(Gitlab::Metrics).to receive(:current_transaction).and_return(transaction) } + + it 'calls the app when metrics are enabled but no timing header is found' do + expect(middleware.call(env)).to eq('yay') + end + + it 'sets proxy_flight_time and calls the app when the header is present' do + env['HTTP_GITLAB_WORHORSE_PROXY_START'] = '123' + expect(transaction).to receive(:set).with(:rails_queue_duration, an_instance_of(Float)) + expect(middleware.call(env)).to eq('yay') + end + end + end +end |