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 bdb822a3ce4301165855b7ce119fa509af7723f0..4ae1a9e996c448c229c1d81de8990fe4f0d720bf 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,11 @@ 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 + result = nil + timed_logger.log_timed('diff_blobs') do + 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) @@ -211,10 +215,14 @@ 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 + result = nil + timed_logger.log_timed('diff_blobs_with_raw_info') do + 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)}" @@ -226,7 +234,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 +247,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 +316,10 @@ def exclusions_manager changes_access: changes_access ) end + + def timed_logger + @changes_access.logger + end end end end