summaryrefslogtreecommitdiff
path: root/lib/gitlab/gitaly_client.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2018-03-06 14:02:18 +0000
committerSean McGivern <sean@gitlab.com>2018-03-13 12:58:00 +0000
commitd30576c5a7197b167d1f2c472361dd4ce77b8262 (patch)
tree46de5962c850ad92d3f0c63e49db538a8c1e329a /lib/gitlab/gitaly_client.rb
parent1bab4dcffc73f8a2aca90d363a6365e71722c535 (diff)
downloadgitlab-ce-d30576c5a7197b167d1f2c472361dd4ce77b8262.tar.gz
Add Gitaly call details to the performance bar
The same as the SQL queries, show the details of Gitaly calls in the performance bar, as a modal that can be opened in the same way.
Diffstat (limited to 'lib/gitlab/gitaly_client.rb')
-rw-r--r--lib/gitlab/gitaly_client.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb
index 9cd76630484..c3aa3ccd7b1 100644
--- a/lib/gitlab/gitaly_client.rb
+++ b/lib/gitlab/gitaly_client.rb
@@ -119,6 +119,8 @@ module Gitlab
#
def self.call(storage, service, rpc, request, remote_storage: nil, timeout: nil)
start = Gitlab::Metrics::System.monotonic_time
+ @last_request = request.is_a?(Google::Protobuf::MessageExts) ? request.to_h : nil
+
enforce_gitaly_request_limits(:call)
kwargs = request_kwargs(storage, timeout, remote_storage: remote_storage)
@@ -258,6 +260,9 @@ module Gitlab
gitaly_migrate_call_duration_seconds.observe({ gitaly_enabled: is_enabled, feature: feature }, total_time)
feature_stack.shift
Thread.current[:gitaly_feature_stack] = nil if feature_stack.empty?
+ add_call_details(feature: feature,
+ duration: total_time,
+ request: is_enabled ? @last_request : {})
end
end
end
@@ -344,6 +349,19 @@ module Gitlab
end
end
+ def self.add_call_details(details)
+ return unless RequestStore.active? && RequestStore.store[:peek_enabled]
+
+ RequestStore.store['gitaly_call_details'] ||= []
+ RequestStore.store['gitaly_call_details'] << details
+ end
+
+ def self.call_details
+ return [] unless RequestStore.active? && RequestStore.store[:peek_enabled]
+
+ RequestStore.store['gitaly_call_details'] || []
+ end
+
def self.expected_server_version
path = Rails.root.join(SERVER_VERSION_FILE)
path.read.chomp