Add feature telemetry for CLI commands#408
Merged
Conversation
177c7f4 to
790548d
Compare
Add TelemetryCollector to cli.Config and pass it from root.go during initialization. Add recordTelemetry helper on Service for nil-safe event recording. Add ErrSSH and ErrPatch sentinel errors with WrapSentinel utility for error classification. Update test helpers to wire a collector into all test setups with drain/find helpers.
Record sandbox.start events with reuse prop for both reattach and new-start paths. Extend SandboxSession with CreatedAt, LastExecAt, and ExecCount fields to power lifecycle metrics. Set CreatedAt when persisting new sandbox sessions.
Record ssh.connect events with success/failure status in both sandbox exec and debug flows. Record ssh.command events with exit_code and interactive flag. Wrap SSH connection failures with ErrSSH sentinel.
Change syncChangesToSandbox and pullChangesFromSandbox signatures to return patch bytes for telemetry tracking. Record sync_push events with patch size, duration, and LFS skip count. Record sync_pull events with patch size, duration, success status, and reject file count. Wrap patch application failures with ErrPatch sentinel for error classification.
Record sandbox.exec events with overall duration, exit code, sync push/ pull timing, and total patch bytes. Update SandboxSession ExecCount and LastExecAt after each exec to support lifecycle analytics.
Record run.initiate event before API call with flags for targeted tasks and initialization parameters.
Record run.complete event when polling detects a completed run, with result status, wait duration, and whether the caller was in wait mode.
Flush() was firing the HTTP POST in a background goroutine, but the CLI exits immediately after calling Flush(), killing the goroutine before the request completes. Make the send synchronous since it only runs at CLI exit.
790548d to
fb1fd94
Compare
jmsanders
approved these changes
Mar 11, 2026
| ErrRetry = errors.New("retry") | ||
| ErrSandboxNoGitDir = errors.New("no .git directory found in sandbox. Set 'preserve-git-dir: true' on your git/clone task") | ||
| ErrSSH = errors.New("ssh error") | ||
| ErrPatch = errors.New("patch error") |
Contributor
There was a problem hiding this comment.
Should this be threaded through the run service as well? Looks like its only used in the sandbox service right now.
Contributor
Author
There was a problem hiding this comment.
Yeah probably - for the sake of size / blast radius, I'll log this as a separate linear issue to do before shipping this
Contributor
Author
There was a problem hiding this comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cli.commandandcli.errortelemetry events recorded at CLI exitFlush()fired the telemetry POST in a background goroutine that was killed before the request completed — now sends synchronously at exitTest plan
service_telemetry_test.go)errors_test.go)