diff options
author | Mark Chao <mchao@gitlab.com> | 2018-09-04 15:36:03 +0300 |
---|---|---|
committer | Mark Chao <mchao@gitlab.com> | 2018-09-05 04:10:19 +0300 |
commit | bec7f0609744025050d7f093f106bfd190813d56 (patch) | |
tree | 14a58ed8201c0e4fd667be4c44e99074c56ed420 /lib | |
parent | 91003c6ebb764c9cf3fe01a14d6213b26c09dcc8 (diff) |
Ignore irrelevant sql commands in metrics
Fix #51005
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/metrics/subscribers/active_record.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/gitlab/metrics/subscribers/active_record.rb b/lib/gitlab/metrics/subscribers/active_record.rb index c205f348023..04107296ae3 100644 --- a/lib/gitlab/metrics/subscribers/active_record.rb +++ b/lib/gitlab/metrics/subscribers/active_record.rb @@ -6,9 +6,15 @@ module Gitlab include Gitlab::Metrics::Methods attach_to :active_record + IGNORABLE_SQL = %w{BEGIN COMMIT}.freeze + def sql(event) return unless current_transaction + payload = event.payload + + return if payload[:name] == 'SCHEMA' || IGNORABLE_SQL.include?(payload[:sql]) + self.class.gitlab_sql_duration_seconds.observe(current_transaction.labels, event.duration / 1000.0) current_transaction.increment(:sql_duration, event.duration, false) |