BigW Consortium Gitlab

Commit 3f9022cf by Rémy Coutable

Merge branch 'zj-peek-gitaly' into 'master'

Show Gitaly data in the peek performance bar Closes #39231 See merge request gitlab-org/gitlab-ce!14949
parents 5295f23b 5e2a748b
- 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