Time to Approve Metric
The Time to Approve Metric measures the time between when a pull request (PR) is first picked up for review and when it receives its first approval. This metric helps engineering teams evaluate the efficiency and responsiveness of their code review process.
Definition
The Time to Approve Metric measures the amount of time it takes for a pull request (PR) to receive its first approval after it has been picked up for review. This metric is a key indicator of the efficiency and responsiveness of the code review process.
Why Is This Metric Useful?
- Process Efficiency: Shorter approval times typically indicate streamlined review workflows and effective team collaboration.
- Quality Assurance: Longer approval times can highlight potential issues, such as unclear PRs, inadequate documentation, or overburdened reviewers.
- Team Productivity: Tracking this metric helps identify bottlenecks in the review process, enabling teams to improve overall productivity.
Factors Influencing Time to Approve
- Clarity of the PR: Well-documented and concise PRs are generally easier to review.
- Complexity of Changes: Intricate logic, algorithms, or domain-specific changes may require additional evaluation.
- Large PRs: Reviewing numerous files or extensive changes can take longer.
- Requested Changes: Reviewers may identify issues that the PR author must address before approval.
- Multiple Review Iterations: Additional rounds of feedback and revisions can extend the time required to reach the first approval.
- Insufficient Tests: Reviewers may request additional tests before approving a PR.
- Interruptions: Reviewers may be interrupted by meetings or higher-priority tasks.
- Skill Gaps: Reviewers may need additional time to understand unfamiliar code, technologies, or domains.
- Reviewer Availability: Approval times may increase when reviewers are unavailable or overallocated.
Monitoring Time to Approve helps engineering teams refine review practices, reduce delays, and support the timely delivery of high-quality code.
Calculation
Time to Approve is calculated as the duration between the moment a PR is picked up for review and the moment it receives its first approval.
A PR is considered picked up when the first reviewer activity occurs, such as a reviewer comment. Comments made by the PR author are excluded from identifying the first reviewer comment.
PR Reviewed and Then Approved
When a reviewer starts reviewing a PR before approving it, the metric measures the elapsed time between the initial review activity and the first approval.
Time to Approve = Time of First Approval - Time the PR Was Picked Up for Review
PR Approved Without Earlier Review Activity
If the first review activity is itself an approval, the PR is considered picked up and approved at the same timestamp.
Time to Approve = 0
Definitions
- Time of First Approval: The timestamp of the first approval recorded for the PR, regardless of whether additional reviews or approvals follow.
- Time the PR Was Picked Up for Review: The timestamp of the first qualifying reviewer activity. If the first qualifying activity is an approval, that approval establishes both timestamps.
- Time of First Reviewer Comment: The timestamp of the first comment made by a reviewer, excluding comments made by the PR author.
Examples for Context
One Review With Approval
A reviewer picks up a PR and subsequently approves it. Time to Approve measures the duration from the initial review activity to the first approval.
Multiple Reviews Before Approval
A PR may go through multiple rounds of review before receiving its first approval. Earlier review activities may include comments or requests for changes; they are not approvals.
The following sequence illustrates the calculation:
| Event | Review Activity | Effect on Time to Approve |
|---|---|---|
| Review 1 | Reviewer comments or requests changes. | Establishes the pickup timestamp if this is the first qualifying reviewer activity. |
| Review 2 | Reviewer provides further feedback or requests additional changes. | No approval has been recorded. The metric continues accumulating time. |
| First Approval | A reviewer approves the PR. | Establishes the first approval timestamp and ends the Time to Approve measurement. |
| Additional Reviews or Approvals | Further review activity may occur. | Does not change the already calculated Time to Approve. |
Time to Approve = First Approval - Review 1
Only Approval Exists
When the first recorded review activity is an approval, the pickup and first approval timestamps are identical. Time to Approve is therefore 0 minutes.
Review Exists Without Approval
If a PR has reviewer activity but has not received an approval, there is no first approval timestamp from which to calculate a completed Time to Approve duration.
No Review Exists
If no qualifying reviewer activity or approval has occurred, the PR has not yet been picked up for review and there is no completed Time to Approve measurement.
How did we do?
Review Time Metric
Time to Merge Metric