Sub topic 14
Measuring Delivery Performance
This chapter assumes you can read a simple pipeline definition, know the difference between continuous integration, continuous delivery, and continuous deployment, and understand how deployment strategies and rollbacks limit the damage from a bad release. Here you learn how to tell whether your pipeline is working, using numbers instead of impressions.
Why measure at all
A pipeline can feel fast and still be slow where it matters. A team may see green builds all day and still wait a week for a change to reach users. Measurement replaces that feeling with data. It also shows where to invest: faster tests, smaller changes, or a safer release process.
Good measurement has two goals:
- Find the bottleneck. Improving a step that is not the bottleneck changes nothing for users.
- Check that speed does not cost stability. A pipeline that ships quickly but breaks production often is not healthy.
The four key delivery metrics
The DORA research program (DevOps Research and Assessment) studied thousands of teams. It found that four metrics describe delivery performance well. Two measure speed (throughput) and two measure stability.
| Metric | What it measures | Kind |
|---|---|---|
| Deployment frequency | How often you release to production | Throughput |
| Lead time for changes | Time from a commit to that change running in production | Throughput |
| Change failure rate | Share of deployments that cause a failure needing a fix, such as a rollback or hotfix | Stability |
| Time to restore service | How long it takes to recover after a failure in production | Stability |
DORA's research reports that high-performing teams do well on all four at once. Speed and stability do not trade off against each other. Small, frequent, automated releases tend to be safer because each one contains little that can go wrong.
Some teams also track a fifth measure, deployment rework rate or reliability. This chapter uses the four above.
Deployment frequency
Count production deployments over a period, such as per day or per week. A team that deploys once a month has a lot of change in each release. A team that deploys many times a day has very little change in each one.
Define "deployment" before counting. Decide whether a canary at 5% of traffic counts, or only a full rollout. Pick one rule and keep it.
Lead time for changes
Lead time runs from the commit (or merge) to the moment that change is live in production. It includes build time, test time, waiting for approval, and waiting for a release window. Often the longest part is waiting, not running.
Break lead time into segments to find where it goes:
- Commit to pipeline start (queue time).
- Pipeline run (build and test).
- Pipeline end to approval (manual gates).
- Approval to production (deploy and rollout).
Change failure rate
Divide the number of deployments that caused a production problem by the total number of deployments. If 3 of 40 deployments needed a rollback or hotfix, the rate is 7.5%.
The hard part is deciding what counts as a failure. Use a rule that you can apply from data, such as "a rollback, a revert commit, or a hotfix deployed within 24 hours."
Time to restore service
Measure from the start of a production failure to the point when users are no longer affected. Rollbacks and feature flags, covered earlier, directly reduce this number because they let you recover without writing and testing a new fix.
Pipeline-level metrics
The four key metrics describe the whole delivery system. Pipeline-level metrics help you diagnose it.
| Metric | Why it matters |
|---|---|
| Pipeline duration | Long runs slow feedback and encourage developers to batch changes |
| Queue time | Time waiting for a runner shows a capacity problem |
| Build success rate | A low rate may mean unstable main or poor local checks |
| Flaky test rate | Tests that fail and pass without code changes erode trust |
| Mean time to fix a broken main | Shows whether the team treats a red build as urgent |
Keep an eye on the median and on the 90th percentile. An average hides the slow runs that people actually complain about.
Collecting the data
Most CI systems expose run history through an API, and many can send events to a monitoring tool. You can start without special tooling. The script below uses the GitHub CLI to pull recent workflow runs and compute a success rate and the median duration.
import json
import statistics
import subprocess
from datetime import datetime
def parse(ts):
return datetime.fromisoformat(ts.replace("Z", "+00:00"))
def fetch_runs(workflow, limit=100):
out = subprocess.run(
[
"gh", "run", "list",
"--workflow", workflow,
"--branch", "main",
"--limit", str(limit),
"--json", "conclusion,startedAt,updatedAt",
],
check=True,
capture_output=True,
text=True,
).stdout
return json.loads(out)
def main():
runs = [r for r in fetch_runs("ci.yml") if r["conclusion"] in ("success", "failure")]
if not runs:
print("No completed runs found")
return
successes = sum(1 for r in runs if r["conclusion"] == "success")
durations = sorted(
(parse(r["updatedAt"]) - parse(r["startedAt"])).total_seconds() / 60
for r in runs
)
p90 = durations[int(0.9 * (len(durations) - 1))]
print(f"Runs analysed: {len(runs)}")
print(f"Success rate: {successes / len(runs):.1%}")
print(f"Median duration: {statistics.median(durations):.1f} min")
print(f"90th percentile: {p90:.1f} min")
main()Run it inside a repository with the GitHub CLI installed and authenticated (gh auth login). The script only reads data. The updatedAt field is an approximation of the finish time, so treat the durations as estimates.
For deployment frequency and lead time, record a timestamp at deploy time and join it to commit timestamps. A common approach is to tag each deployment with the commit SHA, then compare the commit time with the deploy time.
name: record-deploy
on:
workflow_run:
workflows: [ci-cd]
types: [completed]
jobs:
record:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Print deployment record
run: |
echo "sha=${{ github.event.workflow_run.head_sha }}"
echo "deployed_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)"This workflow only prints a record, and the printed line goes to the run log. In practice you would send the same values to a database, a metrics service, or a spreadsheet. Note that it fires when the ci-cd workflow succeeds, which is a stand-in for "the change reached production". If your deploy waits for manual approval, the workflow does not complete until approval and deploy finish, so the timestamp is still reasonable.
Reading the numbers
A number alone says little. Look at trends and at the relationship between metrics.
| Pattern | Likely cause | Where to look |
|---|---|---|
| Long lead time, short pipeline | Waiting on approvals or release windows | Manual gates, release schedule |
| Low deployment frequency, high change failure rate | Large batches of change per release | Batch size, branch lifetime |
| Fast deploys, high change failure rate | Weak automated tests or no progressive rollout | Test coverage, canary use |
| High change failure rate, short restore time | Failures happen, but rollback works | Test quality, still worth reducing |
| Long pipeline duration | Serial jobs, slow tests, cold caches | Parallelism, caching, test selection |
| Many flaky failures | Shared state or timing in tests | Quarantine and fix flaky tests |
Pitfalls in measurement
Metrics are easy to misuse. The most common problems are:
- Using metrics as targets for individuals. When a number becomes a quota, people game it. Splitting one change into five tiny deployments inflates deployment frequency without helping anyone. Use the metrics to study the system, not to rank people.
- Optimizing one metric alone. Pushing deployment frequency without watching change failure rate trades quality for speed.
- Vague definitions. If "failure" or "deployment" changes between reports, trends become meaningless. Write the definitions down.
- Comparing teams. A mobile app released through an app store and an internal web service have different natural limits. Compare a team with its own past.
- Ignoring small samples. With five deployments a month, one failure moves the failure rate by 20 points. Use longer windows.
A practical starting routine
- Write down your definitions of deployment, failure, and restore.
- Record a deploy event with a commit SHA and timestamp for every production release.
- Review the four metrics monthly as a trend, not a score.
- Pick the single worst segment of lead time and improve it.
- Measure again after the change to confirm it helped.
Exercise
A team deploys to production twice a month. Each deployment takes 10 minutes, and their pipeline takes 12 minutes. Their lead time for changes is about 9 days, and 1 of the last 8 deployments needed a rollback. Which metric points to the main problem, and what would you check first?
Show answer
Lead time (9 days) is far larger than the pipeline (12 minutes) plus deploy (10 minutes), so the time goes to waiting, not to automation. Deployment frequency is also low, which suggests large batches and a release schedule. Check the manual approval gates and release windows first. The change failure rate is 1 in 8, or 12.5%. That is worth watching, but smaller and more frequent releases would likely lower it too.
Exercise
Your median pipeline duration is 8 minutes, but developers complain the pipeline is slow. Which additional measurement could explain the complaint, and why?
Show answer
The 90th percentile of duration and the queue time. A median of 8 minutes hides slow runs, such as cache misses or busy periods, and it excludes time spent waiting for a runner before the run starts. Developers experience the slow tail and the queue, not the median.