diff options
| author | Rémy Coutable <remy@rymai.me> | 2016-04-18 14:18:13 +0000 |
|---|---|---|
| committer | Rémy Coutable <remy@rymai.me> | 2016-04-18 14:18:13 +0000 |
| commit | 70e6fa31064984c691e283eddf6712bc031e0842 (patch) | |
| tree | 046241ea901bf2eb6fd4caf859236fdd06933180 | |
| parent | 5ae4fd2181e81f6e75a9d4021fc7d0c4749139ef (diff) | |
| parent | 7e6f0ac0e04c3fa05a8d952bf86463001dc48487 (diff) | |
| download | gitlab-ce-70e6fa31064984c691e283eddf6712bc031e0842.tar.gz | |
Merge branch 'transaction-query-count' into 'master'
Count the number of SQL queries per transaction
cc @pcarranza
See merge request !3783
| -rw-r--r-- | CHANGELOG | 1 | ||||
| -rw-r--r-- | lib/gitlab/metrics/subscribers/active_record.rb | 1 | ||||
| -rw-r--r-- | spec/lib/gitlab/metrics/subscribers/active_record_spec.rb | 3 |
3 files changed, 5 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG index 571c31e63a2..e641adbfcef 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ v 8.7.0 (unreleased) - Method instrumentation now uses Module#prepend instead of aliasing methods - Repository.clean_old_archives is now instrumented - Add support for environment variables on a job level in CI configuration file + - SQL query counts are now tracked per transaction - The Projects::HousekeepingService class has extra instrumentation - All service classes (those residing in app/services) are now instrumented - Developers can now add custom tags to transactions diff --git a/lib/gitlab/metrics/subscribers/active_record.rb b/lib/gitlab/metrics/subscribers/active_record.rb index 8008b3bc895..96cad941d5c 100644 --- a/lib/gitlab/metrics/subscribers/active_record.rb +++ b/lib/gitlab/metrics/subscribers/active_record.rb @@ -9,6 +9,7 @@ module Gitlab return unless current_transaction current_transaction.increment(:sql_duration, event.duration) + current_transaction.increment(:sql_count, 1) end private diff --git a/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb b/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb index 7bc070a4d09..e3293a01207 100644 --- a/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb +++ b/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb @@ -28,6 +28,9 @@ describe Gitlab::Metrics::Subscribers::ActiveRecord do expect(transaction).to receive(:increment). with(:sql_duration, 0.2) + expect(transaction).to receive(:increment). + with(:sql_count, 1) + subscriber.sql(event) end end |
