Commit 5e2a748b authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Add Gitaly data to the Peek performance bar

parent 220a5c37
- local_assigns.fetch(:view)
%strong
%span{ data: { defer_to: "#{view.defer_key}-duration" } } ...
\/
%span{ data: { defer_to: "#{view.defer_key}-calls" } } ...
Gitaly
---
title: Add Gitaly metrics to the performance bar
merge_request:
author:
type: other
......@@ -16,6 +16,7 @@ Peek.into Peek::Views::Redis
Peek.into Peek::Views::Sidekiq
Peek.into Peek::Views::Rblineprof
Peek.into Peek::Views::GC
Peek.into Peek::Views::Gitaly
# rubocop:disable Style/ClassAndModuleCamelCase
class PEEK_DB_CLIENT
......
......@@ -33,6 +33,12 @@ module Gitlab
MUTEX = Mutex.new
private_constant :MUTEX
class << self
attr_accessor :query_time
end
self.query_time = 0
def self.stub(name, storage)
MUTEX.synchronize do
@stubs ||= {}
......@@ -83,11 +89,14 @@ module Gitlab
# end
#
def self.call(storage, service, rpc, request)
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
enforce_gitaly_request_limits(:call)
kwargs = request_kwargs(storage)
kwargs = yield(kwargs) if block_given?
stub(service, storage).__send__(rpc, request, kwargs) # rubocop:disable GitlabSecurity/PublicSend
ensure
self.query_time += Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
end
def self.request_kwargs(storage)
......
module Peek
module Views
class Gitaly < View
def duration
::Gitlab::GitalyClient.query_time
end
def calls
::Gitlab::GitalyClient.get_request_count
end
def results
{ duration: formatted_duration, calls: calls }
end
private
def formatted_duration
ms = duration * 1000
if ms >= 1000
"%.2fms" % ms
else
"%.0fms" % ms
end
end
def setup_subscribers
subscribe 'start_processing.action_controller' do
::Gitlab::GitalyClient.query_time = 0
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment