Skip to content

builds: track queue time separately from build duration#13080

Draft
ericholscher wants to merge 6 commits into
mainfrom
claude/build-queued-duration-tracking-YbGsv
Draft

builds: track queue time separately from build duration#13080
ericholscher wants to merge 6 commits into
mainfrom
claude/build-queued-duration-tracking-YbGsv

Conversation

@ericholscher
Copy link
Copy Markdown
Member

@ericholscher ericholscher commented Jun 1, 2026

Why

Builds can spend time waiting in the queue before a builder picks them up. That wait was previously invisible and impossible to reconstruct for a build that ran a while ago.

Decisions

Stored field vs. computed property. Queue time is task_executed_at - date, which could be a computed property. We store it as a real column instead so it's queryable and cheap to aggregate over historical builds — that querying ability was the whole motivation, and a property can't provide it.

Measured from the original trigger. It's measured from date (set once at creation, never reset on retries) rather than per-attempt, so it captures the total wait even when a build is retried.

Duration is intentionally untouched. length is already measured from when the task starts running, so it never included queue time. Storing queue time separately keeps it that way — queue wait never inflates the reported duration.

finished now derives from execution start. It's computed from task_executed_at + duration (falling back to date for builds predating task_executed_at), so the queue wait isn't counted toward the finish timestamp.

Scope

This PR adds and populates the column going forward. Backfilling the value onto existing builds is split into a stacked PR (#13083) so the one-time data migration can be reviewed and reverted independently.

Notes for reviewers

  • Migration 0073 adds the column (before_deploy).
  • The addons hosting (v1) response embeds the build serializer, so its fixture was updated too.

🤖 Generated by the Claude Code AI agent.

@ericholscher ericholscher force-pushed the claude/build-queued-duration-tracking-YbGsv branch from 959decd to 7f97dab Compare June 1, 2026 12:50
@ericholscher ericholscher force-pushed the claude/build-queued-duration-tracking-YbGsv branch from 7f97dab to 850ac09 Compare June 2, 2026 05:29
claude added 6 commits June 4, 2026 20:04
The build duration (`length`) is measured from when the task actually
starts running on a builder, so time spent waiting in the queue no longer
inflates it. Expose the queued time via a new `Build.queue_time` property
and a `queued` field in the v3 API, and base the API `finished` timestamp
on the execution start (`task_executed_at`) instead of the trigger time.
Rename the v3 API field from `queued` to `queue_time` so it reads
unambiguously as a duration in seconds rather than a build status/state,
matching the `Build.queue_time` property. Also make the docstring state
the unit (seconds) explicitly.
Drop a redundant guard in the v3 `finished` computation (``date`` is
always set, so the fallback is never empty). Add an API test asserting
queue time is reported separately and that ``finished`` is based on the
execution start, not the trigger time.
Replace the computed `Build.queue_time` property with a stored
`IntegerField` so the total queue wait is queryable for historical builds
and cheap to aggregate. It's set in `before_start` from the original
trigger date (`date`) to when the task starts running, so it captures the
full wait even across retries (`date` is never reset). Add a migration and
update the v2 build payload mock to include `date`.
`queue_time` is now a real model field, so the explicit IntegerField
declaration is redundant; ModelSerializer generates it from Meta.fields.
The addons hosting (v1) response embeds the build serializer, which now
includes the `queue_time` field. Update the expected-response fixture.
@ericholscher ericholscher force-pushed the claude/build-queued-duration-tracking-YbGsv branch from 850ac09 to d1128c5 Compare June 4, 2026 20:08
@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 dev | 🛠️ Build #32997407 | 📁 Comparing d1128c5 against latest (e41c7c3)

  🔍 Preview build  

6 files changed · ± 6 modified

± Modified

@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 docs | 🛠️ Build #32997408 | 📁 Comparing d1128c5 against latest (e08ef8f)

  🔍 Preview build  

54 files changed · + 1 added · ± 53 modified

+ Added

± Modified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants