Skip to content

feat(telemetry): instrument startup#943

Open
EhabY wants to merge 3 commits intomainfrom
feat/issue-904-startup-telemetry
Open

feat(telemetry): instrument startup#943
EhabY wants to merge 3 commits intomainfrom
feat/issue-904-startup-telemetry

Conversation

@EhabY
Copy link
Copy Markdown
Collaborator

@EhabY EhabY commented May 7, 2026

Summary

  • Trace activation startup with authState, duration, and result; activation no longer emits granular phase properties.
  • Trace fire-and-forget stored deployment initialization separately as activation.deployment_init.
  • Trace remote.setup with hierarchical child phases: auth_retrieval, workspace_lookup, workspace_ready, agent_ready, and ssh_config_write.
  • Trace CLI binary download and signature verification attempts, including download reason and downloadedBytes once response body bytes are written.
  • Add span-owned property/measurement mutators so telemetry can record values discovered during traced work without mutating caller-owned objects.

Notes

  • Uses the current telemetry span model, so remote phases emit as hierarchical event names like remote.setup.workspace_lookup rather than remote.setup.phase with a phase property.
  • RemoteSetupTelemetry exposes a single typed phase(...) helper instead of one method per phase.
  • cli.download.reason currently supports missing and version_mismatch; there is no true forced-download path in the current CLI manager flow.
  • cli.download.measurements.downloadedBytes is emitted when bytes are written, including failed downloads that wrote a partial body; it is omitted when the server returns HTTP 304 because no response body bytes are written.

Tests

  • pnpm lint
  • pnpm typecheck
  • pnpm test:extension ./test/unit/core/cliManager.test.ts
  • pnpm test:extension ./test/unit/core/cliManager.concurrent.test.ts
  • pnpm test:extension ./test/unit/telemetry/service.test.ts
  • pnpm format:check

Closes #904.

Implementation plan and decisions

Decisions

  1. Remote setup phases follow the current telemetry architecture: hierarchical phase event names such as remote.setup.workspace_lookup, not remote.setup.phase with a phase property.
  2. Activation telemetry preserves existing behavior. Stored deployment initialization remains fire-and-forget and is instrumented separately as activation.deployment_init.
  3. Activation phases were removed from the implementation; the activation event records bounded authState, durationMs, and result.
  4. CLI download byte telemetry records downloadedBytes as bytes are written from an HTTP 200 response, so partial failed downloads retain the last written byte count. HTTP 304 emits cli.download but omits the byte measurement.
  5. cli.download reasons use what the current code can determine. Current code supports missing and version_mismatch; there is no true forced download path today.
  6. ServiceContainer is still constructed before initVscodeProposed; construction does not call proposed APIs, and proposed API usage remains after initialization.

Implementation

  • Wire TelemetryService into CliManager through ServiceContainer.
  • Add Span.setProperty and Span.setMeasurement, with TelemetryService copying caller-owned objects at span start.
  • Split startup instrumentation helpers into activation and remote setup modules.
  • Instrument activation with TelemetryService.trace("activation", ...), using bounded authState values.
  • Preserve fire-and-forget deployment initialization and attach telemetry via the existing promise chain.
  • Instrument Remote.setup() with TelemetryService.trace("remote.setup", ...) and child phases.
  • Keep phase wrapping at the orchestration level in remote.ts while calling helper methods without telemetry where possible.
  • Instrument actual CLI download attempts with cli.download.
  • Instrument signature verification attempts with cli.verify.
  • Add targeted unit tests around span mutation isolation, CLI download measurements, partial download error telemetry, and CLI telemetry behavior.

Generated by Coder Agents.

@EhabY EhabY self-assigned this May 7, 2026
@EhabY EhabY force-pushed the feat/issue-904-startup-telemetry branch 2 times, most recently from f726148 to 2758a44 Compare May 7, 2026 12:07
@EhabY EhabY changed the title feat: instrument startup telemetry feat(telemetry): instrument startup telemetry May 7, 2026
@EhabY EhabY changed the title feat(telemetry): instrument startup telemetry feat(telemetry): instrument startup May 7, 2026
@EhabY EhabY force-pushed the feat/issue-904-startup-telemetry branch from 2758a44 to da3d8dc Compare May 7, 2026 12:53
@EhabY EhabY force-pushed the feat/issue-904-startup-telemetry branch 4 times, most recently from 620ce09 to 495e0c1 Compare May 7, 2026 14:28
EhabY and others added 2 commits May 7, 2026 18:07
- Bundle activation tracer methods (setAuthState, traceDeploymentInit) into a span-scoped ActivationTracer interface; drop instance-state from ActivationTelemetry
- Mirror the same shape for remote.setup: RemoteSetupTracer exposes phase() and is owned by RemoteSetupTelemetry; remote.ts no longer touches Span directly
- Build RemoteSetupContext after auth retrieval (no empty-default mutation); group setup args under args; rename baseUrlRaw -> baseUrl
- Reuse AuthorityParts from util instead of synthesizing a local alias
- Drop redundant post-download recordDownloadedBytes and the BinaryDownloadResult/DownloadResult types; per-chunk progress already records the final value
- Adopt createTestTelemetryService helper in commandManager.test.ts
@EhabY EhabY force-pushed the feat/issue-904-startup-telemetry branch from 495e0c1 to 374c156 Compare May 7, 2026 15:08
@EhabY EhabY requested a review from ethanndickson May 7, 2026 17:01
@EhabY
Copy link
Copy Markdown
Collaborator Author

EhabY commented May 8, 2026

/coder-agents-review

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 startup path (activation, remote setup, CLI binary)

1 participant