Skip to content

feat(builds): export container-build resource metrics - #658

Merged
ImLunaHey merged 3 commits into
mainfrom
luna/dep-7981-build-metrics-cli
Nov 20, 2026
Merged

ImLunaHey merged 3 commits into
mainfrom
luna/dep-7981-build-metrics-cli

Conversation

@ImLunaHey

@ImLunaHey ImLunaHey commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Container-build resource measurements are available through the API but cannot be exported from the CLI. Add two read-only commands:

depot builds metrics --project <project-id> --start <timestamp> --end <timestamp> -o csv
depot builds analytics --project <project-id> --start <timestamp> --end <timestamp> -o table
  • Table, JSON, and CSV output; explicit completion windows; bounded per-build pagination and server-computed project/architecture summaries.
  • Organization-token authorization, observed capacity, sample counts, duration weighting, and missing values preserved separately from measured zeroes.
  • Published protobuf bindings and documentation covering executor-only collection, units, coverage, and retention.

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 builds command group so container-build CPU and memory measurements can be pulled from the CLI, with metrics (one paginated page of per-build, per-machine stats) and analytics (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 and docs/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.

@linear-code

linear-code Bot commented Nov 3, 2026

Copy link
Copy Markdown

DEP-7981

@ImLunaHey
ImLunaHey marked this pull request as ready for review November 20, 2026 16:38

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: medium. Approved. Cursor Bugbot completed successfully with no findings that need human review, and this read-only CLI metrics export stays within the approval threshold.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ID and depot.json fallback and the --token / DEPOT_TOKEN fallback also behave as the help text says.
  • Checked how output.go treats 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 through cell() before going to the terminal.
  • Looked at the generic-error path, where requestError keeps 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.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review found no issues

No high-confidence issues detected in this change.

@ImLunaHey
ImLunaHey merged commit 704482c into main Nov 20, 2026
13 checks passed
@ImLunaHey
ImLunaHey deleted the luna/dep-7981-build-metrics-cli branch November 20, 2026 18:20
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.

1 participant