Skip to content

feat(auth-server): tag auth.strategy.used metric with route path#20765

Merged
vbudhram merged 1 commit into
mainfrom
fxa-13948
Jun 23, 2026
Merged

feat(auth-server): tag auth.strategy.used metric with route path#20765
vbudhram merged 1 commit into
mainfrom
fxa-13948

Conversation

@vbudhram

@vbudhram vbudhram commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Because

  • The Hawk to Bearer token migration could not be observed per endpoint; the auth.strategy.used counter carried only scheme and kind, so adoption couldn't be broken down by route.

This pull request

  • Adds a templated path tag to auth.strategy.used in the Hawk and Bearer FxA-token schemes (hawk-fxa-token.js, bearer-fxa-token.js).
  • Uses req.route.path (templated route, never the raw URL) so cardinality stays bounded at ~2 schemes × authed routes.
  • Falls back to path:unknown when the route is unavailable.
  • Updates hawk-fxa-token.spec.ts and bearer-fxa-token.spec.ts to assert the new tag.

Issue that this pull request solves

Closes: https://mozilla-hub.atlassian.net/browse/FXA-13948

Checklist

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

Other information

  • Metric change only; no behavior change to authentication. Per-endpoint adoption becomes visible in StatsD/Grafana once deploy

@vbudhram vbudhram requested a review from a team as a code owner June 18, 2026 17:20
Copilot AI review requested due to automatic review settings June 18, 2026 17:20
@vbudhram vbudhram self-assigned this Jun 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves observability of the ongoing Hawk → Bearer FxA-token migration by adding a bounded-cardinality path tag (templated route path) to the auth.strategy.used StatsD counter, enabling per-endpoint adoption tracking.

Changes:

  • Tag auth.strategy.used with path:${req.route?.path ?? 'unknown'} in both Hawk and Bearer FxA-token auth schemes.
  • Update Hawk and Bearer auth-scheme unit tests to assert the new path tag is included in the emitted metric.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/fxa-auth-server/lib/routes/auth-schemes/hawk-fxa-token.js Adds path tag to the auth.strategy.used increment for Hawk auth.
packages/fxa-auth-server/lib/routes/auth-schemes/bearer-fxa-token.js Adds path tag to the auth.strategy.used increment for Bearer auth.
packages/fxa-auth-server/lib/routes/auth-schemes/hawk-fxa-token.spec.ts Extends metric assertion to include the new path tag.
packages/fxa-auth-server/lib/routes/auth-schemes/bearer-fxa-token.spec.ts Extends metric assertion to include the new path tag.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vbudhram vbudhram merged commit 1c2de0f into main Jun 23, 2026
17 of 19 checks passed
@vbudhram vbudhram deleted the fxa-13948 branch June 23, 2026 19:56
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.

3 participants