Skip to content

feat(telemetry): instrument auth and workspace state#948

Open
EhabY wants to merge 3 commits into
mainfrom
feat/issue-906-auth-workspace-telemetry
Open

feat(telemetry): instrument auth and workspace state#948
EhabY wants to merge 3 commits into
mainfrom
feat/issue-906-auth-workspace-telemetry

Conversation

@EhabY
Copy link
Copy Markdown
Collaborator

@EhabY EhabY commented May 12, 2026

Summary

  • instrument OAuth token refresh, 401 recovery, and modal login prompt telemetry
  • record deduped workspace and selected-agent state transition telemetry with observed transition durations
  • trace workspace update trigger attempts while relying on existing remote.setup.workspace_ready for full readiness timing

Closes #906.

Validation

  • pnpm test:extension ./test/unit/oauth/sessionManager.test.ts ./test/unit/api/authInterceptor.test.ts ./test/unit/login/loginCoordinator.test.ts ./test/unit/remote/workspaceStateMachine.test.ts ./test/unit/workspace/workspaceMonitor.test.ts
  • pnpm typecheck
  • pnpm lint
  • pnpm format:check
  • pnpm test:extension
Implementation plan and decisions

Confirmed adjustment:

  • Replace the issue's explicit workspace.start / workspace.stop events with transition telemetry that better matches the current architecture:
    • workspace.state_transitioned
    • workspace.agent.state_transitioned
  • Keep:
    • workspace.update.triggered
    • auth events from the issue (auth.token_refresh, auth.intercept_401, auth.login_prompt)

Implemented:

  • Added typed instrumentation helpers in src/instrumentation/auth.ts and src/instrumentation/workspace.ts.
  • Wired auth telemetry through optional TelemetryReporter injection.
  • Recorded workspace transitions from WorkspaceMonitor and selected-agent transitions from WorkspaceStateMachine.
  • Recorded observedDurationMs between observed transitions where available.
  • Added TestSink coverage for auth events, update trigger events, and workspace/agent transition events.

Generated by Coder Agents.

@EhabY EhabY self-assigned this May 12, 2026
EhabY and others added 2 commits May 12, 2026 20:47
- workspace.ts: inline single-use transition helpers, unify on the
  spread idiom for optional `observedDurationMs`, move `performance.now()`
  below the dedup early-return, drop the no-op `() => fn()` wrapper in
  `traceUpdateTriggered`, and make `INITIAL_STATE` private.
- auth.ts: replace the `T extends LoginPromptResult` constraint with a
  `LoginPromptTracer` exposing `markAborted()`, matching the
  `RemoteSetupTracer` pattern. Callers now drive abort signaling, so
  telemetry no longer depends on `LoginResult`'s shape.
- loginCoordinator: call `tracer.markAborted()` on `!result.success`.
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 auth and workspace lifecycle

1 participant