2018-09-04 13:14:22 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# This module adds additional performance metrics to the grape logger
|
|
|
|
module Gitlab
|
|
|
|
module GrapeLogging
|
|
|
|
module Loggers
|
|
|
|
class PerfLogger < ::GrapeLogging::Loggers::Base
|
|
|
|
def parameters(_, _)
|
2019-07-17 19:34:27 -04:00
|
|
|
gitaly_data.merge(rugged_data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def gitaly_data
|
|
|
|
gitaly_calls = Gitlab::GitalyClient.get_request_count
|
|
|
|
|
|
|
|
return {} if gitaly_calls.zero?
|
|
|
|
|
2019-03-27 06:56:36 -04:00
|
|
|
{
|
|
|
|
gitaly_calls: Gitlab::GitalyClient.get_request_count,
|
|
|
|
gitaly_duration: Gitlab::GitalyClient.query_time_ms
|
|
|
|
}
|
2018-09-04 13:14:22 -04:00
|
|
|
end
|
2019-07-17 19:34:27 -04:00
|
|
|
|
|
|
|
def rugged_data
|
|
|
|
rugged_calls = Gitlab::RuggedInstrumentation.query_count
|
|
|
|
|
|
|
|
return {} if rugged_calls.zero?
|
|
|
|
|
|
|
|
{
|
|
|
|
rugged_calls: rugged_calls,
|
|
|
|
rugged_duration_ms: Gitlab::RuggedInstrumentation.query_time_ms
|
|
|
|
}
|
|
|
|
end
|
2018-09-04 13:14:22 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|