diff options
author | Sean McGivern <sean@gitlab.com> | 2018-03-08 15:10:59 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-03-13 17:09:42 +0300 |
commit | 582447d9ae0074e0843c60df92d7c2ab09b23c80 (patch) | |
tree | 5239568d0b6fbb8a077e51f1a6091ad7f5e51fb9 /lib/gitlab/gitaly_client.rb | |
parent | 5bfa93e38ac56f22a71d2d0720e523a5acda12ee (diff) |
Capture Gitaly calls that don't go through `migrate`
Diffstat (limited to 'lib/gitlab/gitaly_client.rb')
-rw-r--r-- | lib/gitlab/gitaly_client.rb | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb index c3aa3ccd7b1..8ca30ffc232 100644 --- a/lib/gitlab/gitaly_client.rb +++ b/lib/gitlab/gitaly_client.rb @@ -119,7 +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 + request_hash = request.is_a?(Google::Protobuf::MessageExts) ? request.to_h : {} + @current_call_id ||= SecureRandom.uuid enforce_gitaly_request_limits(:call) @@ -137,6 +138,10 @@ module Gitlab gitaly_controller_action_duration_seconds.observe( current_transaction_labels.merge(gitaly_service: service.to_s, rpc: rpc.to_s), duration) + + add_call_details(id: @current_call_id, feature: service, duration: duration, request: request_hash) + + @current_call_id = nil end def self.handle_grpc_unavailable!(ex) @@ -254,15 +259,16 @@ module Gitlab feature_stack.unshift(feature) begin start = Gitlab::Metrics::System.monotonic_time + @current_call_id = SecureRandom.uuid + call_details = { id: @current_call_id } yield is_enabled ensure total_time = Gitlab::Metrics::System.monotonic_time - start 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 : {}) + + add_call_details(call_details.merge(feature: feature, duration: total_time)) end end end @@ -350,16 +356,19 @@ module Gitlab end def self.add_call_details(details) - return unless RequestStore.active? && RequestStore.store[:peek_enabled] + id = details.delete(:id) + + return unless id && RequestStore.active? && RequestStore.store[:peek_enabled] - RequestStore.store['gitaly_call_details'] ||= [] - RequestStore.store['gitaly_call_details'] << details + RequestStore.store['gitaly_call_details'] ||= {} + RequestStore.store['gitaly_call_details'][id] ||= {} + RequestStore.store['gitaly_call_details'][id].merge!(details) end - def self.call_details - return [] unless RequestStore.active? && RequestStore.store[:peek_enabled] + def self.list_call_details + return {} unless RequestStore.active? && RequestStore.store[:peek_enabled] - RequestStore.store['gitaly_call_details'] || [] + RequestStore.store['gitaly_call_details'] || {} end def self.expected_server_version |