Skip to content

feat: add auth telemetry lifecycle traces#994

Merged
EhabY merged 6 commits into
mainfrom
feat/auth-telemetry-lifecycle
Jun 10, 2026
Merged

feat: add auth telemetry lifecycle traces#994
EhabY merged 6 commits into
mainfrom
feat/auth-telemetry-lifecycle

Conversation

@EhabY

@EhabY EhabY commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add auth login/logout outcome traces with bounded source/method/reason properties
  • add credential store/clear traces with keyring mode, credential category, bounded failure category, and duration
  • add deployment suspended/recovered/cross-window/auth-config-recovery-failed lifecycle events
  • add representative command, coordinator, credential, deployment, and auth telemetry tests

Closes #984

Validation

  • pnpm format:check
  • pnpm lint
  • pnpm typecheck
  • pnpm test:extension ./test/unit/core/cliCredentialManager.test.ts ./test/unit/login/loginCoordinator.test.ts ./test/unit/core/cliManager.test.ts ./test/unit/deployment/deploymentManager.test.ts ./test/unit/instrumentation/auth.test.ts ./test/unit/commands.test.ts
Implementation notes
  • Command login owns the outer auth.login span so command/auto-login/switch-deployment sources and URL-prompt cancellation are captured once.
  • LoginCoordinator.ensureLoggedIn({ traceLogin: false }) is only used from that command-owned span to avoid emitting a second direct-login span for the same attempt.
  • Direct coordinator callers, including URI login, keep default login tracing.
  • Credential store/clear events are emitted around the credential manager operations, separate from logout outcome telemetry.

Generated by Coder Agents for @EhabY.

@EhabY EhabY self-assigned this Jun 8, 2026
@EhabY EhabY force-pushed the feat/auth-telemetry-lifecycle branch from 5df69b2 to 23f7ba4 Compare June 9, 2026 12:40
EhabY and others added 2 commits June 9, 2026 14:00
- Revert cliCredentialManager from `#` fields back to `private` to cut diff
- Restore parallel file/keyring deletion in deleteToken
- Drop the failure-category return threaded up to logout; record credential
  failures on the auth.credential.clear span at the source instead
- Pass span last and grouped ({ signal, span }) into deleteKeyringToken
- Remove the loginMethods identity map, dead AuthLoginMethod/AuthLoginReason,
  unused "direct" source, and collapse the record-* helpers to one
- Drop redundant setMethod calls now that traceLogin records method on return
- Rename commands.test.ts -> commands.telemetry.test.ts
- Fix uriHandler tests broken by the telemetry service dependency
@EhabY EhabY requested a review from DanielleMaywood June 9, 2026 18:20

@DanielleMaywood DanielleMaywood left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a stylistic question about the async function drop. Not blocking, just curious.

commands.telemetry.test.ts has many as unknown as. I understand why we're leaning to them but it does pain me and it'd be nice if we could have a good solution that doesn't require that.

Comment on lines -62 to +77
public async storeToken(
public storeToken(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come we've dropped the async? I might just have a knowledge gap with JS practices but I'd have assumed we'd keep this function as async and call await on our credentialTelemetry.traceStore.

@EhabY EhabY Jun 10, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have lint rules that remove the async when there are no await, it might still be an async function that returns a promise but in this case we just have to return said promise without waiting

There is no advantage to just calling doing return promise over return await promise unless we want to catch errors, then the latter makes sense. Otherwise it's just noise

Comment thread src/core/cliCredentialManager.ts
Comment thread src/instrumentation/auth.ts
Comment thread src/instrumentation/auth.ts
Comment thread src/instrumentation/credentials.ts
Comment thread test/unit/commands.telemetry.test.ts Outdated
Make telemetry dimensions explicit at every call site: suspendSession
and clearDeployment now require a reason instead of defaulting (the
suspendSession default was never used in production), and
CliCredentialManager requires its TelemetryReporter rather than
silently falling back to the noop reporter.

Replace the scenario DSL in commands.telemetry.test.ts with plain it()
blocks on a shared setup() that reuses createTelemetryHarness, and drop
the unused clearDeploymentError option.
@EhabY EhabY force-pushed the feat/auth-telemetry-lifecycle branch from 4c71534 to 9f32eec Compare June 10, 2026 11:41
@EhabY EhabY merged commit b10b32c into main Jun 10, 2026
13 checks passed
@EhabY EhabY deleted the feat/auth-telemetry-lifecycle branch June 10, 2026 11:50
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, deployment, and credential lifecycle

2 participants