From 65b670e43c97c8f0a38b62dc528afd1fcbe6d200 Mon Sep 17 00:00:00 2001 From: Craig Smith <5344211-craigmsmith@users.noreply.gitlab.com> Date: Thu, 23 Oct 2025 14:07:23 +1000 Subject: [PATCH 1/2] Add log_timed to GRPC calls --- .../payload_processor.rb | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/ee/lib/gitlab/checks/secret_push_protection/payload_processor.rb b/ee/lib/gitlab/checks/secret_push_protection/payload_processor.rb index bdb822a3ce4301..63cc459c0930db 100644 --- a/ee/lib/gitlab/checks/secret_push_protection/payload_processor.rb +++ b/ee/lib/gitlab/checks/secret_push_protection/payload_processor.rb @@ -189,7 +189,9 @@ def diff_blobs(paths_slice) right_blob: path.new_blob_id ) end - project.repository.diff_blobs(blob_pair_ids, patch_bytes_limit: PAYLOAD_BYTES_LIMIT).to_a + timed_logger.log_timed('diff_blobs') do + project.repository.diff_blobs(blob_pair_ids, patch_bytes_limit: PAYLOAD_BYTES_LIMIT).to_a + end end def diff_blobs_with_raw_info(paths_slice) @@ -211,10 +213,12 @@ def diff_blobs_with_raw_info(paths_slice) end begin - project.repository.diff_blobs_with_raw_info( - raw_info_data, - patch_bytes_limit: PAYLOAD_BYTES_LIMIT - ).to_a + timed_logger.log_timed('diff_blobs_with_raw_info') do + project.repository.diff_blobs_with_raw_info( + raw_info_data, + patch_bytes_limit: PAYLOAD_BYTES_LIMIT + ).to_a + end rescue StandardError secret_detection_logger.error( "diff_blobs_with_raw_info Gitaly call failed with args: #{raw_info_data.map(&:inspect)}" @@ -226,7 +230,10 @@ def diff_blobs_with_raw_info(paths_slice) def get_diffs diffs = [] # Get new commits - commits = project.repository.new_commits(revisions) + commits = [] + timed_logger.log_timed('new_commits') do + commits = project.repository.new_commits(revisions) + end diff_filters = [ :DIFF_STATUS_ADDED, @@ -236,9 +243,12 @@ def get_diffs :DIFF_STATUS_RENAMED ] - # Get changed paths - paths = project.repository.find_changed_paths(commits, merge_commit_diff_mode: :all_parents, - find_renames: true, diff_filters: diff_filters) + paths = [] + timed_logger.log_timed('find_changed_paths') do + # Get changed paths + paths = project.repository.find_changed_paths(commits, merge_commit_diff_mode: :all_parents, + find_renames: true, diff_filters: diff_filters) + end # Reject diff blob objects from paths that are excluded # -- TODO: pass changed paths with diff blob objects and move this exclusion process into the gem. @@ -302,6 +312,10 @@ def exclusions_manager changes_access: changes_access ) end + + def timed_logger + @changes_access.logger + end end end end -- GitLab From cf34073babc85c2bd148bb8516a69b85958b52f2 Mon Sep 17 00:00:00 2001 From: Craig Smith <5344211-craigmsmith@users.noreply.gitlab.com> Date: Thu, 23 Oct 2025 14:57:29 +1000 Subject: [PATCH 2/2] Fix test --- .../checks/secret_push_protection/payload_processor.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ee/lib/gitlab/checks/secret_push_protection/payload_processor.rb b/ee/lib/gitlab/checks/secret_push_protection/payload_processor.rb index 63cc459c0930db..4ae1a9e996c448 100644 --- a/ee/lib/gitlab/checks/secret_push_protection/payload_processor.rb +++ b/ee/lib/gitlab/checks/secret_push_protection/payload_processor.rb @@ -189,9 +189,11 @@ def diff_blobs(paths_slice) right_blob: path.new_blob_id ) end + result = nil timed_logger.log_timed('diff_blobs') do - project.repository.diff_blobs(blob_pair_ids, patch_bytes_limit: PAYLOAD_BYTES_LIMIT).to_a + result = project.repository.diff_blobs(blob_pair_ids, patch_bytes_limit: PAYLOAD_BYTES_LIMIT).to_a end + result end def diff_blobs_with_raw_info(paths_slice) @@ -213,12 +215,14 @@ def diff_blobs_with_raw_info(paths_slice) end begin + result = nil timed_logger.log_timed('diff_blobs_with_raw_info') do - project.repository.diff_blobs_with_raw_info( + result = project.repository.diff_blobs_with_raw_info( raw_info_data, patch_bytes_limit: PAYLOAD_BYTES_LIMIT ).to_a end + result rescue StandardError secret_detection_logger.error( "diff_blobs_with_raw_info Gitaly call failed with args: #{raw_info_data.map(&:inspect)}" -- GitLab