diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-25 21:08:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-25 21:08:50 +0300 |
commit | ad7ce32986c4b9e4af87c2895ef9a867cc5bb356 (patch) | |
tree | e8a8e9291434658484024ff00e236908123eb037 /spec/initializers/lograge_spec.rb | |
parent | 65f5f75e3a3b0b9f4ea6035294f81977fa8a2bb5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/initializers/lograge_spec.rb')
-rw-r--r-- | spec/initializers/lograge_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/initializers/lograge_spec.rb b/spec/initializers/lograge_spec.rb index 4d10d218606..de722764bf4 100644 --- a/spec/initializers/lograge_spec.rb +++ b/spec/initializers/lograge_spec.rb @@ -152,5 +152,35 @@ RSpec.describe 'lograge', type: :request do expect(log_data['etag_route']).to eq(etag_route) end end + + context 'with transaction' do + let(:transaction) { Gitlab::Metrics::WebTransaction.new({}) } + + before do + allow(Gitlab::Metrics::Transaction).to receive(:current).and_return(transaction) + end + + context 'when RequestStore is enabled', :request_store do + context 'with db payload' do + it 'includes db counters', :request_store do + ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);') + subscriber.process_action(event) + + expect(log_data).to include("db_count" => 1, "db_write_count" => 0, "db_cached_count" => 0) + end + end + end + + context 'when RequestStore is disabled' do + context 'with db payload' do + it 'does not include db counters' do + ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);') + subscriber.process_action(event) + + expect(log_data).not_to include("db_count" => 1, "db_write_count" => 0, "db_cached_count" => 0) + end + end + end + end end end |