Class: Gitlab::Database::RecordCountMonitor
- Inherits:
-
Object
- Object
- Gitlab::Database::RecordCountMonitor
- Defined in:
- lib/gitlab/database/record_count_monitor.rb
Constant Summary collapse
- THRESHOLD =
1_000
Class Method Summary collapse
Class Method Details
.subscribe ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/gitlab/database/record_count_monitor.rb', line 8 def self.subscribe return if @subscribed ActiveSupport::Notifications.subscribe('sql.active_record') do |event| next unless event.payload[:row_count] next if event.payload[:row_count] <= THRESHOLD warn_large_result_set(event.payload) end @subscribed = true end |
.warn_large_result_set(payload) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/gitlab/database/record_count_monitor.rb', line 21 def self.warn_large_result_set(payload) = "Query fetched #{payload[:row_count]} rows (threshold: #{THRESHOLD})" += "\nSQL: #{payload[:sql]}" if payload[:sql] Gitlab::AppLogger.warn() end |