2018-11-19 21:01:13 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-01-15 10:21:04 -05:00
|
|
|
module Gitlab
|
|
|
|
module QueryLimiting
|
|
|
|
class ActiveSupportSubscriber < ActiveSupport::Subscriber
|
|
|
|
attach_to :active_record
|
|
|
|
|
2018-02-21 00:27:05 -05:00
|
|
|
def sql(event)
|
2021-08-13 14:09:11 -04:00
|
|
|
return if !::Gitlab::QueryLimiting::Transaction.current || event.payload.fetch(:cached, event.payload[:name] == 'CACHE')
|
2021-03-07 19:09:10 -05:00
|
|
|
|
2022-04-27 11:10:01 -04:00
|
|
|
::Gitlab::QueryLimiting::Transaction.current.increment(event.payload[:sql])
|
2021-08-13 14:09:11 -04:00
|
|
|
::Gitlab::QueryLimiting::Transaction.current.executed_sql(event.payload[:sql])
|
2018-01-15 10:21:04 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|