Skip to content

Auth metrics updates #63030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 7, 2025
Merged

Auth metrics updates #63030

merged 2 commits into from
Aug 7, 2025

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Aug 1, 2025

  • Change user.is_authenticated to aspnetcore.user.is_authenticated. Feedback at Add ASP.NET Core AuthN and AuthZ metrics open-telemetry/semantic-conventions#2531 (comment) is there isn't a standard on attributes for user.* so we shouldn't use it. It could be aspnetcore.user.is_authenticated or aspnetcore.identity.is_authenticated
  • Change metric units to not all be {request}.
    • Authorization API isn't tied to HTTP requests so it doesn't make sense there.
    • While the authentication API does take HttpContext as an argument, so involves requests, I think there are better units.

@Copilot Copilot AI review requested due to automatic review settings August 1, 2025 06:07
@JamesNK JamesNK added the area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer label Aug 1, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

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 updates authentication and authorization metrics to improve naming conventions and accuracy. The changes align with OpenTelemetry semantic conventions by using namespaced attributes and more precise metric units.

  • Change metric attribute from user.is_authenticated to aspnetcore.user.is_authenticated to follow OpenTelemetry semantic conventions
  • Rename metric units from generic {request} to more specific units like {attempt}, {challenge}, {forbid}, {sign_in}, and {sign_out}
  • Update method names to better reflect the actual operations being measured

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Security/Authorization/Core/src/DefaultAuthorizationServiceImpl.cs Updates method calls from AuthorizedRequestCompleted to AuthorizeAttemptCompleted
src/Security/Authorization/Core/src/AuthorizationMetrics.cs Renames metrics infrastructure with more accurate terminology and updates attribute naming
src/Http/Authentication.Core/src/AuthenticationMetrics.cs Updates metric units to be more specific to the actual operations being measured

@JamesNK JamesNK requested a review from MackinnonBuck August 1, 2025 10:38
Copy link
Member

@MackinnonBuck MackinnonBuck left a comment

Choose a reason for hiding this comment

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

Thanks!

@JamesNK JamesNK merged commit 0e8cbde into main Aug 7, 2025
30 checks passed
@JamesNK JamesNK deleted the jamesnk/auth-metrics branch August 7, 2025 00:22
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-rc1 milestone Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants