Repository navigation
feat(builds): export container-build resource metrics - #658
Conversation
There was a problem hiding this comment.
I reviewed this PR and didn't find any bugs. It adds a new user-facing command group that depends on new server RPCs and has its own token rules, so a human should still look at it before it merges.
What was reviewed:
- Checked option resolution in
builds.go: output auto-detection, the RFC 3339 and millisecond parsing, and the seven-day / no-future / no-pre-1970 checks. The project,DEPOT_PROJECT_IDanddepot.jsonfallback and the--token/DEPOT_TOKENfallback also behave as the help text says. - Checked how
output.gotreats nil versus zero. Missing values print blank in CSV and n/a in tables, a build with no machines still gets a CSV row, and IDs, architecture and the page token pass throughcell()before going to the terminal. - Looked at the generic-error path, where
requestErrorkeeps only the connect code and drops the server message. It looks deliberate and I didn't treat it as a bug, but it does make failures harder to diagnose.
Extended reasoning...
The change adds a new depot builds command group with two subcommands (metrics and analytics). It covers about 360 lines of command and output code plus about 350 lines of tests, a README section and a new docs page. It also bumps the generated buf.build depot API bindings to pick up two new CoreBuild RPCs. The security-sensitive part is authentication: the commands accept only an organization token from --token or DEPOT_TOKEN and send it with read-only requests; there is no injection or write path. I deferred because this is a sizeable new product surface tied to server-side rollout, and it embeds API and token design choices that a maintainer should sign off on. No CODEOWNERS file covers these paths, and the timeline has no outstanding reviewer objections.
This review covers commit a85df02, which is no longer the latest commit on this pull request; later commits are not covered by it.


Container-build resource measurements are available through the API but cannot be exported from the CLI. Add two read-only commands:
Validation: full Go suite, focused race tests, golangci-lint, module verification, native binary build, npm format/type checks, and read-only live checks for pagination and JSON/CSV agreement passed. Hosted CI and review pending.
Keep as draft through the collector soak. Merge and release after rollout approval.
Refs DEP-7981.
Catch up on this pull request in Depot
Note
Low Risk
Read-only commands with organization-token auth and bounded queries; no changes to build execution or credential storage.
Overview
Adds a new
depot buildscommand group so container-build CPU and memory measurements can be pulled from the CLI, withmetrics(one paginated page of per-build, per-machine stats) andanalytics(API-computed project and architecture summaries).Both subcommands require an organization API token, a resolved project, and a bounded completion-time window (up to seven days). They support table, JSON, and CSV output, preserve missing telemetry instead of zero-filling, and surface pagination tokens on stderr for
metrics. Documentation is added in the README anddocs/build-metrics.md, and the command is registered on the root CLI alongside broad Go tests for validation, errors, cancellation, and safe table rendering.Reviewed by Cursor Bugbot for commit 5065ac3. Bugbot is set up for automated code reviews on this repo. Configure here.