Add Gitaly data to the Peek performance bar
This commit is contained in:
parent
220a5c3759
commit
5e2a748bb7
5 changed files with 56 additions and 0 deletions
7
app/views/peek/views/_gitaly.html.haml
Normal file
7
app/views/peek/views/_gitaly.html.haml
Normal file
|
@ -0,0 +1,7 @@
|
|||
- local_assigns.fetch(:view)
|
||||
|
||||
%strong
|
||||
%span{ data: { defer_to: "#{view.defer_key}-duration" } } ...
|
||||
\/
|
||||
%span{ data: { defer_to: "#{view.defer_key}-calls" } } ...
|
||||
Gitaly
|
5
changelogs/unreleased/zj-peek-gitaly.yml
Normal file
5
changelogs/unreleased/zj-peek-gitaly.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
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)
|
||||
|
|
34
lib/peek/views/gitaly.rb
Normal file
34
lib/peek/views/gitaly.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
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
|
Loading…
Reference in a new issue