Skip to content

feat(telemetry): instrument auth recovery#962

Merged
EhabY merged 2 commits into
mainfrom
feat/issue-906-auth-telemetry
May 18, 2026
Merged

feat(telemetry): instrument auth recovery#962
EhabY merged 2 commits into
mainfrom
feat/issue-906-auth-telemetry

Conversation

@EhabY
Copy link
Copy Markdown
Collaborator

@EhabY EhabY commented May 18, 2026

Summary

Records local telemetry for the OAuth and 401-recovery paths so latency and failure modes show up alongside the rest of the local telemetry stream.

Auth events (src/instrumentation/auth.ts):

  • auth.token_refreshed: OAuth refresh attempt with trigger (background / reactive).
  • auth.token_refresh.deduped: emitted when a refresh call joins an in-flight refresh so the dropped trigger stays countable.
  • auth.unauthorized_intercepted: recovery path for a 401, with recovery (refresh_success / login_required / none) and refreshAttempted.
  • auth.login_prompted: modal login prompt outcome, with trigger and a reason on abort/failure.

Alongside the auth instrumentation, the shared telemetry plumbing picks up a measurements argument on TelemetryService.trace, span outcome helpers (markFailure / markAborted), typed properties on Span, and test helpers (enableLocalTelemetry, TestSink.expectOne, createMockServiceContainer). The SSH and WebSocket instrumentation modules migrate to the typed property API.

Split

First of two stacked PRs replacing #948 (closing #906 in two pieces). The workspace half is #963 and depends on this PR — its remote.ts diff stacks on the auth-side diff here.

Records local telemetry for the OAuth and 401-recovery paths so latency
and failure modes are visible alongside the rest of the local telemetry
stream.

- `auth.token_refreshed`: OAuth refresh attempt with `trigger`
  (`background` / `reactive`).
- `auth.token_refresh.deduped`: emitted when a refresh call joins an
  in-flight refresh so the dropped trigger stays countable.
- `auth.unauthorized_intercepted`: recovery path for a 401, with
  `recovery` (`refresh_success` / `login_required` / `none`) and
  `refreshAttempted`.
- `auth.login_prompted`: modal login prompt outcome, with `trigger`
  and a `reason` on abort/failure.

The shared `TelemetryService.trace` API gains a `measurements` argument,
`span.markFailure`/`markAborted` for non-success outcomes, and reads
typed properties on `Span`. The SSH and WebSocket instrumentation
modules migrate to the typed property API. Test helpers add
`enableLocalTelemetry`, `TestSink.expectOne`, and
`createMockServiceContainer`.

Closes part of #906.
Comment thread src/instrumentation/auth.ts Outdated
Comment thread src/instrumentation/auth.ts Outdated
Comment thread src/api/authInterceptor.ts
Comment thread src/instrumentation/auth.ts
Comment thread src/login/loginCoordinator.ts Outdated
Comment thread src/telemetry/service.ts Outdated
Comment thread src/telemetry/span.ts Outdated
Comment thread test/unit/deployment/deploymentManager.test.ts Outdated
- drop unneeded comments on LoginPromptReason / AuthRecoveryRecorder / SpanResult
- rename tokenRefreshDeduped -> logTokenRefreshDeduped to match trace*/log* convention
- flatten recoverFromUnauthorized with guard clauses
- revert LoginCoordinator to inline private readonly constructor params
- rename normalizeProps -> stringifyProps
- drop `as unknown as TelemetryService` cast in deploymentManager test
@EhabY EhabY requested a review from DanielleMaywood May 18, 2026 16:08
@EhabY EhabY merged commit 56f0596 into main May 18, 2026
13 checks passed
@EhabY EhabY deleted the feat/issue-906-auth-telemetry branch May 18, 2026 16:21
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.

2 participants