feat(telemetry): instrument auth recovery#962
Merged
Conversation
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.
This was referenced May 18, 2026
- 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
DanielleMaywood
approved these changes
May 18, 2026
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
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 withtrigger(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, withrecovery(refresh_success/login_required/none) andrefreshAttempted.auth.login_prompted: modal login prompt outcome, withtriggerand areasonon abort/failure.Alongside the auth instrumentation, the shared telemetry plumbing picks up a
measurementsargument onTelemetryService.trace, span outcome helpers (markFailure/markAborted), typed properties onSpan, 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.tsdiff stacks on the auth-side diff here.