2016-01-14 18:37:52 +05:30
|
|
|
module Gitlab
|
|
|
|
module Metrics
|
|
|
|
module Subscribers
|
|
|
|
# Class for tracking the total query duration of a transaction.
|
|
|
|
class ActiveRecord < ActiveSupport::Subscriber
|
|
|
|
attach_to :active_record
|
|
|
|
|
|
|
|
def sql(event)
|
|
|
|
return unless current_transaction
|
|
|
|
|
|
|
|
current_transaction.increment(:sql_duration, event.duration)
|
2016-06-02 11:05:42 +05:30
|
|
|
current_transaction.increment(:sql_count, 1)
|
2016-01-14 18:37:52 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def current_transaction
|
|
|
|
Transaction.current
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|