Conversation
| Example: ` depot ci metrics att_123 | ||
| depot ci metrics --attempt att_123 --output json | ||
| depot ci metrics --job job_123 --output json | ||
| depot ci metrics --run run_123 --output json`, | ||
| RunE: func(cmd *cobra.Command, args []string) error { |
There was a problem hiding this comment.
will workflowid as a filter come later?
There was a problem hiding this comment.
Yes, workflow filtering is a later pass. This CLI change mirrors the current public run/job/attempt metrics RPCs and keeps workflow selection out of this already-large PR. -watts[bot]
| } | ||
| } | ||
|
|
||
| func metricStatsJSON(stats *civ1.CIMetricsStats) statsJSON { |
There was a problem hiding this comment.
metricStatsJSON handles scalar fields with nil-safe getters, but then reads optional pointer fields directly from stats. Since this proto message field is nullable on the Go client, an omitted stats message would panic here instead of emitting an empty stats block. Can we guard stats == nil or normalize it to an empty CIMetricsStats before reading the optional fields?
There was a problem hiding this comment.
Yep, fixed in 4f9d544. metricStatsJSON now returns an empty stats object when the message is omitted, so the optional pointer fields are never read through nil. -watts[bot]
| if stats.GetObservedStartedAt() != "" || stats.GetObservedFinishedAt() != "" { | ||
| fmt.Printf(" Observed: %s - %s\n", stats.GetObservedStartedAt(), stats.GetObservedFinishedAt()) | ||
| } | ||
| if stats.PeakCpuUtilization != nil || stats.AverageCpuUtilization != nil { |
There was a problem hiding this comment.
Same nil-stats issue on the text path: the code calls nil-safe getters first, but then directly checks stats.PeakCpuUtilization / stats.AverageCpuUtilization. A response with stats omitted will panic while rendering human output. A small helper that returns empty stats for nil would cover both JSON and text formatting.
There was a problem hiding this comment.
Fixed in 4f9d544 as well. The text renderer now normalizes missing stats to an empty CIMetricsStats before reading optional CPU or memory pointers. -watts[bot]
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue. You can view the agent here.
Reviewed by Cursor Bugbot for commit 4f9d544. Configure here.
| cmd.AddCommand(NewCmdCancel()) | ||
| cmd.AddCommand(NewCmdDispatch()) | ||
| cmd.AddCommand(NewCmdLogs()) | ||
| cmd.AddCommand(NewCmdMetrics()) |
There was a problem hiding this comment.
New "metrics" command missing from registration guard test
Low Severity
The new metrics subcommand is registered in NewCmdCI but not added to the wanted slice in TestCICommandRegistration in ci_test.go. That test's comment explicitly says "New verbs should be added to the wanted slice below." Without the entry, a future refactor that accidentally drops cmd.AddCommand(NewCmdMetrics()) won't be caught by the guard test.
Reviewed by Cursor Bugbot for commit 4f9d544. Configure here.


Summary
depot ci metricsgives humans and scripts the metrics view the app already had.What was happening
The CLI could inspect CI status and logs, but it had no command for CPU and memory metrics. Customers writing scripts or agents had no clean way to ask for attempt samples or job/run metric summaries.
What happens now
depot ci metrics <attempt-id>plus explicit--attempt,--job, and--runselectors.--output text|json, with deterministic snake_case JSON for automation.available,no_sandbox,no_time_range, andno_samples.Anything else?
This is the CLI half of DEP-4265 and depends on the API draft: https://github.com/depot/api/pull/3638
Note
Medium Risk
Adds new CLI surface area and new CI RPC wrappers for metrics retrieval; main risk is output/flag behavior changes and handling of large metric responses via new error paths.
Overview
Adds
depot ci metricsto fetch CI CPU/memory metrics at the attempt, job, or run level (positional attempt ID or mutually-exclusive--attempt|--job|--run), with--output text|jsonand deterministic snake_case JSON payloads.Extends the CI API client wrappers with
CIGetJobAttemptMetrics,CIGetJobMetrics, andCIGetRunMetrics, and adds targeted error handling forResourceExhausted(actionable “narrow your request” guidance) andNotFound(suggests using job/run selectors).Reviewed by Cursor Bugbot for commit d124c87. Bugbot is set up for automated code reviews on this repo. Configure here.