2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module Peek
|
|
|
|
module Views
|
2019-10-12 21:52:04 +05:30
|
|
|
class Gitaly < DetailedView
|
2019-12-04 20:38:33 +05:30
|
|
|
DEFAULT_THRESHOLDS = {
|
|
|
|
calls: 30,
|
|
|
|
duration: 1000,
|
|
|
|
individual_call: 500
|
|
|
|
}.freeze
|
|
|
|
|
|
|
|
THRESHOLDS = {
|
|
|
|
production: {
|
|
|
|
calls: 30,
|
|
|
|
duration: 1000,
|
|
|
|
individual_call: 500
|
|
|
|
}
|
|
|
|
}.freeze
|
|
|
|
|
|
|
|
def self.thresholds
|
|
|
|
@thresholds ||= THRESHOLDS.fetch(Rails.env.to_sym, DEFAULT_THRESHOLDS)
|
|
|
|
end
|
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
private
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def duration
|
2019-12-04 20:38:33 +05:30
|
|
|
::Gitlab::GitalyClient.query_time * 1000
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def calls
|
|
|
|
::Gitlab::GitalyClient.get_request_count
|
|
|
|
end
|
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
def call_details
|
2018-05-09 12:01:36 +05:30
|
|
|
::Gitlab::GitalyClient.list_call_details
|
|
|
|
end
|
|
|
|
|
|
|
|
def format_call_details(call)
|
|
|
|
pretty_request = call[:request]&.reject { |k, v| v.blank? }.to_h.pretty_inspect
|
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
super.merge(request: pretty_request || {})
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|