Merge Request Average Lifetime

Purpose

Merge Request Average Lifetime shows an average speed of new changes being incorporated to a master code due to delays on code reviews. The less the better - means less overhead for a development process/team to handle merges.

Terminology alignment

PERF supports multiple variations of GIT, which have a different naming for the piece of code change willing to be merged to some target branch through the process of code review. Just to remove the confusion, this metric represents a holistic approach for:

Type of a GIT

Term

Type of a GIT

Term

GitLab

Merge request

GitHub

Pull request

Bitbucket

Pull request

Azure DevOps Repos

Pull request

How metric helps

It allows monitoring aged merge requests, on average, by weeks. Stale merge requests, i.e. which took long time for reviewed and acceptance, usually have a higher cost for a team in comparison with short-living merges. Why? Stale merges require more attention at review and acceptance of a code change - because of higher probability of conflicts with a target branch.

Possible reasons why stale merge requests might appear:

  • risky merge e.g. due to a not-easy-to-review change or a big change

  • not enough capacity (or level of engineering culture) in the team to review the code on timely basis

General recommendation is to have the lifetime of merge requests as small as possible. 

How metric works

Chart overview

Chart shows Merge Request Average Lifetime in hours (axis Y) by week (axis X). Chart can consist of several series according to a number of branches selected in Project Settings.

Only accepted merge requests take part in this metric. Merge requests pending review are not counted here, no matter how long they stay open.

By click on a series a hint with additional details appears:

  • Branch - branch name; got from Project settings

  • Week - time period the series is built for

  • Merge Requests accepted - number of accepted requests

  • Average Merge Requests lifetime - lifetime, in hours, for the merge requests accepted during this week 

  • Longest Merge Requests - top 5 merge requests with the longest lifetime at that week

Next to the chart name there is a link to navigate to the GIT repository ('arrow' icon) for further details. 

Calculation formula

Tmr = Tmerge - Tcreation

Merge Request Average Lifetime = ∑Tmr/Nmr

where

Tmr - time spent for a merge request

Nmr - number of all merge requests existing

Notices:

  • Cancelled requests are NOT included in calculation.

  • Merge requests are distributed between weeks in the chart by their merge date.



RAG thresholds: Red > 240 hours, Green < 120 hours (can be adjusted per project). 

Data Source

Data for the metric can be collected from GIT.