Skip to content

Add metrics to Identity #62078

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Add metrics to Identity #62078

wants to merge 8 commits into from

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).

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
2 participants