ad1c71663f
This uses an ActiveRecord subscriber to get queries and calculate the total query time from that. This means that the total will always be consistent with the queries in the table. It does however mean that we could potentially miss some queries that don't go through ActiveRecord. Making this change also allows us to unify the response JSON a little bit, making the frontend slightly simpler as a result.
42 lines
794 B
Ruby
42 lines
794 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Peek
|
|
module Views
|
|
class Rugged < DetailedView
|
|
def results
|
|
return {} unless calls > 0
|
|
|
|
super
|
|
end
|
|
|
|
private
|
|
|
|
def duration
|
|
::Gitlab::RuggedInstrumentation.query_time
|
|
end
|
|
|
|
def calls
|
|
::Gitlab::RuggedInstrumentation.query_count
|
|
end
|
|
|
|
def call_details
|
|
::Gitlab::RuggedInstrumentation.list_call_details
|
|
end
|
|
|
|
def format_call_details(call)
|
|
super.merge(args: format_args(call[:args]))
|
|
end
|
|
|
|
def format_args(args)
|
|
args.map do |arg|
|
|
# Needed to avoid infinite as_json calls
|
|
if arg.is_a?(Gitlab::Git::Repository)
|
|
arg.to_s
|
|
else
|
|
arg
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|