8000 Add metrics to Identity by JamesNK · Pull Request #62078 · dotnet/aspnetcore · GitHub
[go: up one dir, main page]

Skip to content

Conversation

JamesNK
Copy link
Member
@JamesNK JamesNK commented May 23, 2025

Fixes #52996

@JamesNK
Copy link
Member Author
JamesNK commented Jul 1, 2025

Ready to review. Please take a look.

@JamesNK
Copy link
Member Author
JamesNK commented Jul 1, 2025

@MackinnonBuck I've added metrics to some of the passkey methods you recently added.

@JamesNK JamesNK requested a review from Copilot July 1, 2025 05:50
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 instruments UserManager and SignInManager with OpenTelemetry-compatible metrics, extends test helpers to support metrics collection, and updates existing tests and project references to validate the new metrics.

  • Introduces UserManagerMetrics and SignInManagerMetrics and registers them via DI
  • Augments MockHelpers and TestUserManager/TestSignInManager to accept an IMeterFactory and emit metrics
  • Updates tests across Identity.Test to assert that the correct tags are recorded for each metric

Reviewed Changes

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

Show a summary per file
File Description
src/Identity/Extensions.Core/src/UserManagerMetrics.cs New metrics class for user manager operations
src/Identity/Extensions.Core/src/UserManager.cs Instruments all public methods to record metrics and exposes ServiceProvider
src/Identity/Core/src/SignInManagerMetrics.cs New metrics class for sign-in manager operations
src/Identity/Core/src/SignInManager.cs Instruments sign-in methods to record metrics
src/Identity/test/Shared/MockHelpers.cs MockUserManager/TestUserManager updated to accept IMeterFactory
src/Identity/test/Shared/MetricsHelpers.cs New helper for asserting metric tag collections
src/Identity/test/Identity.Test/UserManagerTest.cs Tests updated to collect and assert on emitted metrics
src/Http/Authentication.Core/src/AuthenticationService.cs Minor doc-comment fix in authentication service
src/Http/Authentication.Abstractions/src/IAuthenticationService.cs Minor doc-comment fix in auth service interface
Comments suppressed due to low confidence (3)

src/Identity/Extensions.Core/src/UserManager.cs:1255

  • Method name 'ResolveFromtRolesCoreAsync' contains a typo and is inconsistent with the public API. Rename it to 'RemoveFromRolesCoreAsync' to match 'RemoveFromRolesAsync'.
            throw;

src/Http/Authentication.Core/src/AuthenticationService.cs:148

  • [nitpick] The doc comment has a redundant 'in'; consider revising to 'Sign in a principal for the specified authentication scheme.'
    /// Sign in a principal in for the specified authentication scheme.

src/Http/Authentication.Abstractions/src/IAuthenticationService.cs:43

  • [nitpick] The doc comment has a redundant 'in'; consider revising to 'Sign in a principal for the specified authentication scheme.'
    /// Sign in a principal in for the specified authentication scheme.

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.

Are we considering RoleManager out of scope for these metrics?

@JamesNK JamesNK force-pushed the jamesnk/identity-metrics branch from a637d35 to c3cb40e Compare July 4, 2025 03:36
@JamesNK
Copy link
Member Author
JamesNK commented Jul 4, 2025

API review feedback applied.

Please do a final review and lets get this merged 🙏

@JamesNK
Copy link
Member Author
JamesNK commented Jul 5, 2025

/azp run

Copy link
Azure Pipelines successfully started running 3 pipeline(s).

@JamesNK
Copy link
Member Author
JamesNK commented Jul 7, 2025

/azp run

Copy link
Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Member
@halter73 halter73 left a comment

Choose a reason for hiding this comment

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

Do you think it's worth it to file an issue for RoleManager metrics like @MackinnonBuck suggested?

@JamesNK
Copy link
Member Author
JamesNK commented Jul 9, 2025

/azp run

Copy link
Azure Pipelines successfully started running 3 pipeline(s).

@JamesNK JamesNK merged commit e4748a3 into main Jul 10, 2025
29 checks passed
@JamesNK JamesNK deleted the jamesnk/identity-metrics branch July 10, 2025 01:12
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview7 milestone Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-identity Includes: Identity and providers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Record metrics for user account activities

3 participants

0