Remove merge_request_metrics_outside_merge_transaction feature flag

Removes the merge_request_metrics_outside_merge_transaction feature flag. It has been enabled for 100% of projects on GitLab.com since 2026-09-24 with no regressions, so MergeRequests::PostMergeService now always computes the merge request metrics before the post-merge event transaction opens.

Detailed context for AI agents

What does this MR do and why?

  • Drops the Feature.enabled? guard around metrics_service.prepare_merge_data in MergeRequests::PostMergeService#create_event, so the EE Analytics::MergeRequestMetricsCalculator reads (every commit and diff file of the MR from Gitaly) always happen before Event.transaction opens rather than inside it.
  • Deletes the flag definition config/feature_flags/gitlab_com_derisk/merge_request_metrics_outside_merge_transaction.yml.
  • Removes the flag-disabled spec context in spec/services/merge_requests/post_merge_service_spec.rb. The remaining example asserts the ordering prepare_merge_data -> Event.transaction -> merge.

Behaviour kept: the EE MergeRequestMetricsService#merge fallback @calculated_merge_data || calculated_merge_data is unchanged, so merge still works if called without prepare_merge_data (covered by ee/spec/services/ee/merge_request_metrics_service_spec.rb). No schema or data change; the values written to merge_request_metrics are identical with the flag on or off.

Rollout history (from the rollout issue): staging 2026-09-17, gitlab-org/gitlab 2026-09-18, 20% of projects 2026-09-22, 50% 2026-09-23, 100% 2026-09-24. Watched MergeWorker error ratio and DB duration on the Sidekiq worker detail dashboard and the PatroniLongRunningTransactionDetected alerts; nothing regressed.

References

Screenshots or screen recordings

Not applicable, backend-only flag removal.

How to set up and validate locally

  1. Merge any merge request on an EE GDK.
  2. In the Rails console confirm the metrics were written: MergeRequest.last.metrics.slice(:merged_at, :commits_count, :added_lines, :removed_lines).

Verification

  • bundle exec rspec spec/services/merge_requests/post_merge_service_spec.rb - 26 examples, 0 failures.
  • Rubocop clean on both changed Ruby files.

MR acceptance checklist

Evaluated against the MR acceptance checklist. Flag removal only, no new risk in quality, performance, reliability, security, or maintainability.

Merge request reports

Loading
Loading