Add timing logging to MergeRequests::RefreshService methods
What does this MR do and why?
This MR adds structured logging for key operations in the MergeRequests::RefreshService to help identify performance bottlenecks. This addresses the performance issues reported in #548046 where UpdateMergeRequestsWorker is not meeting the 10-second SLO targets on GitLab Dedicated instances.
What are the relevant issue numbers?
#548046
Logging Details
The following methods now have their execution time logged to Kibana:
-
find_new_commits_duration- Time spent finding new commits -
close_upon_missing_source_branch_ref_duration- Time spent closing MRs with missing source branches -
post_merge_manually_merged_duration- Time spent processing manually merged MRs -
link_forks_lfs_objects_duration- Time spent linking LFS objects from forks -
reload_merge_requests_duration- Time spent reloading merge request diffs -
remove_requested_changes_duration- Time spent removing requested changes (EE only) -
other_method_calls_duration- Time spent on other operations (suggestions, auto-merges, todos, notifications, etc.)
Each method's duration is measured independently using Gitlab::Metrics::System.monotonic_time to provide accurate timing information.
Feature Flag
The logging is controlled by the :log_refresh_service_duration feature flag (experiment type, default: disabled). This allows for safe rollout and testing on specific instances.
To enable:
Feature.enable(:log_refresh_service_duration, User.find_by_username('username'))``
Edited by Marc Shaw