gitlab-org--gitlab-foss/lib/gitlab/query_limiting/active_support_subscriber.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
512 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module Gitlab
module QueryLimiting
class ActiveSupportSubscriber < ActiveSupport::Subscriber
attach_to :active_record
def sql(event)
return if !::Gitlab::QueryLimiting::Transaction.current || event.payload.fetch(:cached, event.payload[:name] == 'CACHE')
::Gitlab::QueryLimiting::Transaction.current.increment(event.payload[:sql])
::Gitlab::QueryLimiting::Transaction.current.executed_sql(event.payload[:sql])
end
end
end
end