Skip to content

PRs opened as drafts report near-zero Lead Time #698

Description

@hhaiyang

Description:

If you open a PR as a draft and mark it ready for review later, the time it sat in draft never shows up in the Lead Time breakdown. None of the five segments cover that window. And because Lead Time is just the five segments added together, that time disappears from the total too.

The total in the breakdown should match the real time the change took — first commit to deployment. For draft PRs it doesn't, and the gap is exactly the draft duration.

Steps to reproduce:

  1. Open a PR as a draft right after pushing your first commit.
  2. Leave it in draft for a while (say, overnight).
  3. Mark it ready for review.
  4. Approve straight away.
  5. Merge. Let the deploy workflow run.
  6. Wait for the next sync.
  7. Look at the team's Lead Time breakdown and compare the sum of the five segments to the actual time from first commit to deploy.

Expected behavior:

The "Commit" segment (first_commit_to_open) should measure the time from the first commit up to when the PR is ready for review, instead of up to when the PR was created. For PRs opened directly as non-draft, behaviour is unchanged (PR creation and ready-for-review happen at the same instant). For PRs opened as drafts, the draft duration becomes part of the Commit segment.

Actual behavior:

Time (UTC) Event Δ
Mon 14:43:08 First commit
Mon 14:43:28 PR opened (as draft) +20s
Mon 14:43:28 → Tue 08:23:15 PR sits in draft +17h 39m 47s
Tue 08:23:15 ready_for_review event
Tue 08:24:46 Reviewer approves +1m 31s
Tue 08:24:57 PR merged +11s
Tue 08:25:37 Deploy workflow run_started_at +40s

Using the timeline from above, the dashboard reports a Lead Time of 2m 42s for a PR that actually took ~17h 42m from first commit to deploy. The ~17h 39m the PR sat in draft isn't counted anywhere — first_commit_to_open stops at pr.created_at and first_response_time starts at ready_for_review, so the draft window falls between them and gets dropped from the sum.

Image

Additional context

#634

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions