2018-10-08 10:50:39 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-18 07:26:00 -04:00
|
|
|
module Peek
|
|
|
|
module Views
|
2019-07-24 10:42:45 -04:00
|
|
|
class Gitaly < DetailedView
|
2019-08-06 11:04:43 -04:00
|
|
|
DEFAULT_THRESHOLDS = {
|
|
|
|
calls: 30,
|
2019-09-03 08:13:36 -04:00
|
|
|
duration: 1000,
|
|
|
|
individual_call: 500
|
2019-08-06 11:04:43 -04:00
|
|
|
}.freeze
|
|
|
|
|
|
|
|
THRESHOLDS = {
|
|
|
|
production: {
|
|
|
|
calls: 30,
|
2019-09-03 08:13:36 -04:00
|
|
|
duration: 1000,
|
|
|
|
individual_call: 500
|
2019-08-06 11:04:43 -04:00
|
|
|
}
|
|
|
|
}.freeze
|
|
|
|
|
|
|
|
def self.thresholds
|
|
|
|
@thresholds ||= THRESHOLDS.fetch(Rails.env.to_sym, DEFAULT_THRESHOLDS)
|
|
|
|
end
|
|
|
|
|
2019-07-24 10:42:45 -04:00
|
|
|
private
|
|
|
|
|
2017-10-18 07:26:00 -04:00
|
|
|
def duration
|
2019-09-03 08:13:36 -04:00
|
|
|
::Gitlab::GitalyClient.query_time * 1000
|
2017-10-18 07:26:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def calls
|
|
|
|
::Gitlab::GitalyClient.get_request_count
|
|
|
|
end
|
|
|
|
|
2019-07-24 10:42:45 -04:00
|
|
|
def call_details
|
2018-03-08 07:10:59 -05:00
|
|
|
::Gitlab::GitalyClient.list_call_details
|
2018-03-06 09:02:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def format_call_details(call)
|
2018-03-08 07:10:59 -05:00
|
|
|
pretty_request = call[:request]&.reject { |k, v| v.blank? }.to_h.pretty_inspect
|
2018-03-06 09:02:18 -05:00
|
|
|
|
2019-07-26 09:03:00 -04:00
|
|
|
super.merge(request: pretty_request || {})
|
2018-03-06 09:02:18 -05:00
|
|
|
end
|
|
|
|
|
2017-10-18 07:26:00 -04:00
|
|
|
def setup_subscribers
|
|
|
|
subscribe 'start_processing.action_controller' do
|
|
|
|
::Gitlab::GitalyClient.query_time = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|