Commit 046295d3 authored by Stan Hu's avatar Stan Hu

Fix Gitaly duration timings for conflict and search RPCs

For many Gitaly RPCs, previously the `gitaly_duration_s` log timings
only accounted for the initial request/response time. We now measure the
total time it takes to consume the streaming response for the following
RPCs:

1. ListConflictFiles
2. SearchFilesByContent

Part of https://gitlab.com/gitlab-org/gitlab/-/issues/30334
parent 081d1801
---
title: Fix Gitaly duration timings for conflicts and search RPCs
merge_request: 34909
author:
type: other
......@@ -20,10 +20,10 @@ module Gitlab
our_commit_oid: @our_commit_oid,
their_commit_oid: @their_commit_oid
)
response = GitalyClient.call(@repository.storage, :conflicts_service, :list_conflict_files, request, timeout: GitalyClient.long_timeout)
GitalyClient.streaming_call(@repository.storage, :conflicts_service, :list_conflict_files, request, timeout: GitalyClient.long_timeout) do |response|
GitalyClient::ConflictFilesStitcher.new(response, @gitaly_repo)
end
end
def conflicts?
list_conflict_files.any?
......
......@@ -334,10 +334,10 @@ module Gitlab
def search_files_by_content(ref, query, options = {})
request = Gitaly::SearchFilesByContentRequest.new(repository: @gitaly_repo, ref: ref, query: query)
response = GitalyClient.call(@storage, :repository_service, :search_files_by_content, request, timeout: GitalyClient.default_timeout)
GitalyClient.streaming_call(@storage, :repository_service, :search_files_by_content, request, timeout: GitalyClient.default_timeout) do |response|
search_results_from_response(response, options)
end
end
def disconnect_alternates
request = Gitaly::DisconnectGitAlternatesRequest.new(
......@@ -403,14 +403,18 @@ module Gitlab
def gitaly_fetch_stream_to_file(save_path, rpc_name, request_class, timeout)
request = request_class.new(repository: @gitaly_repo)
response = GitalyClient.call(
GitalyClient.streaming_call(
@storage,
:repository_service,
rpc_name,
request,
timeout: timeout
)
) do |response|
write_stream_to_file(response, save_path)
end
end
def write_stream_to_file(response, save_path)
File.open(save_path, 'wb') do |f|
response.each do |message|
f.write(message.data)
......
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