2019-07-21 01:34:46 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Peek
|
|
|
|
module Views
|
2019-07-24 10:42:45 -04:00
|
|
|
class Rugged < DetailedView
|
|
|
|
def results
|
|
|
|
return {} unless calls > 0
|
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-07-21 01:34:46 -04:00
|
|
|
def duration
|
2019-08-06 11:04:43 -04:00
|
|
|
::Gitlab::RuggedInstrumentation.query_time_ms
|
2019-07-21 01:34:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def calls
|
|
|
|
::Gitlab::RuggedInstrumentation.query_count
|
|
|
|
end
|
|
|
|
|
2019-07-24 10:42:45 -04:00
|
|
|
def call_details
|
2019-07-21 01:34:46 -04:00
|
|
|
::Gitlab::RuggedInstrumentation.list_call_details
|
|
|
|
end
|
|
|
|
|
|
|
|
def format_call_details(call)
|
2019-07-26 09:03:00 -04:00
|
|
|
super.merge(args: format_args(call[:args]))
|
2019-07-21 01:34:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def format_args(args)
|
|
|
|
args.map do |arg|
|
2019-07-31 18:38:02 -04:00
|
|
|
# ActiveSupport::JSON recursively calls as_json on all
|
|
|
|
# instance variables, and if that instance variable points to
|
|
|
|
# something that refers back to the same instance, we can wind
|
|
|
|
# up in an infinite loop. Currently this only seems to happen with
|
|
|
|
# Gitlab::Git::Repository and ::Repository.
|
|
|
|
if arg.instance_variables.present?
|
2019-07-21 01:34:46 -04:00
|
|
|
arg.to_s
|
|
|
|
else
|
|
|
|
arg
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|