What is this metric?
The average code changes (in Lines of Code) of PRs in the selected time range.
Why is it important?
Small PRs can reduce risks of introducing new bugs and increase code review quality, as problems may often be hidden in big chuncks of code and difficult to identify.
Which dashboard(s) does it exist in?
How is it calculated?
This metric is calculated by counting the total number of code changes (in LOC) divided by the total number of PRs in the selected time range.Data Sources Required
This metric relies on PRs/MRs collected from GitHub, GitLab, BitBucket, Gitee or other code review tools.Data Transformation Required
If you want to measure the monthly trend of
PR review time in the screenshot below, please run the following SQL in Grafana.
with _pr_commits_data as(
DATE_ADD(date(pr.created_date), INTERVAL -$interval(date(pr.created_date))+1 DAY) as time,
pr.id as pr_id,
sum(c.additions)+sum(c.deletions) as loc
left join pull_request_commits prc on pr.id = prc.pull_request_id
left join commits c on prc.commit_sha = c.sha
and pr.base_repo_id in ($repo_id)
group by 1,2,3
sum(loc)/count(distinct pr_id) as 'PR Size'
GROUP BY 1
How to improve?
- Divide coding tasks into workable and manageable pieces;
- Encourage developers to submit small PRs and only keep related changes in the same PR.