blob: 96cad941d5c208420313fbbceb8709b31afeee4e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
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)
current_transaction.increment(:sql_count, 1)
end
private
def current_transaction
Transaction.current
end
end
end
end
end
|