Skip to content

feat: add telemetry for CLI and remote setup#993

Merged
EhabY merged 7 commits into
mainfrom
feat/985-telemetry-traces
Jun 11, 2026
Merged

feat: add telemetry for CLI and remote setup#993
EhabY merged 7 commits into
mainfrom
feat/985-telemetry-traces

Conversation

@EhabY

@EhabY EhabY commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds structured, bounded telemetry traces for the CLI and remote-setup flows:

  • cli.resolve parent trace with bounded child phases — cache_lookup, version_check, download_decision, lock_wait/lock_wait_recheck, and fallback_to_existing_binary — surfaced on the parent as a single outcome, cache_source, version_check, download_reason, and a typed failure_category.
  • cli.download with reason and a downloaded_bytes measurement, plus a cli.download.verify child phase for signature verification.
  • cli.configure with silent, credential_source, a typed failure_category, result, and duration.
  • remote.setup child phases for CLI resolve/configure, compatibility check, workspace lookup/monitor/ready, agent resolve, SSH config/monitor, and connection handoff, with a typed outcome for non-throwing early exits.
  • WebSocket reconnect aggregate telemetry extended with attempts, max_backoff_ms, and total_duration_ms measurements.

Attribute names follow the #996 conventions: snake_case keys and subject-first phase names.

Implementation notes

  • Telemetry is threaded explicitly via a trace/span callback arg. Public methods (fetchBinary, configure) are thin telemetry wrappers over private implementations, keeping instrumentation out of the business logic.
  • cli.configure failures are categorized from a typed CredentialFileError thrown by the storage layer rather than from error-shape heuristics.
  • Multi-arg internal methods group their value params into an options object, with the cross-cutting trace/span as the trailing argument.
  • The cliManager unit and telemetry tests share a setupCliManager() harness — per-test setup returning local mocks plus scenario builders — so the two files no longer duplicate setup.

Verification

  • pnpm typecheck
  • pnpm lint
  • pnpm test (1928 passed, 1 skipped)
  • pnpm format:check

Closes #985

@EhabY EhabY self-assigned this Jun 8, 2026
@EhabY EhabY force-pushed the feat/985-telemetry-traces branch 2 times, most recently from faddf2d to 08be5c9 Compare June 9, 2026 12:29
@EhabY EhabY requested a review from ethanndickson June 9, 2026 18:19
@EhabY EhabY force-pushed the feat/985-telemetry-traces branch from 3bd8d11 to 69d562d Compare June 10, 2026 12:03
EhabY and others added 6 commits June 10, 2026 18:10
- Make fetchBinary/configure thin telemetry wrappers over private impls;
  thread trace as the trailing arg and group value params into an options object
- Inline getDownloadAction and fold cli.ts phase helpers (downloadDecision,
  tracedPhase) for a smaller instrumentation surface
- Categorize configure failures via a typed CredentialFileError instead of
  error-shape heuristics
- Extract remote.setup compatibility check into checkCompatibility
- Share a setupCliManager() harness across the cliManager unit and telemetry
  tests; per-test setup with local mocks, no beforeEach
Rename CliTelemetry span wrappers to the trace<Noun> form used across
src/instrumentation (traceResolve, traceDownload, traceConfigure) and
CliConfigureTrace outcome methods to the shared cancel/fail verb pair.
@EhabY EhabY force-pushed the feat/985-telemetry-traces branch from 69d562d to 092212b Compare June 10, 2026 15:10
Comment thread test/unit/core/cliManager.telemetry.test.ts
Comment thread src/instrumentation/cli.ts Outdated
Comment thread src/instrumentation/cli.ts
- Record error.type via the shared recordError/recordAborted helpers
  instead of failure_category, using abort_stage for cancellation, to
  match the instrumentation conventions.
- Replace the no-op download_decision phase with download_reason and
  download_action properties on cli.resolve.
- Carry the fallback's error.type on the parent resolve span and record
  fallback_reason for why the fallback was triggered.
@EhabY EhabY merged commit c9314a5 into main Jun 11, 2026
13 checks passed
@EhabY EhabY deleted the feat/985-telemetry-traces branch June 11, 2026 10:47
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.

Telemetry: instrument CLI resolution and remote setup phases

2 participants