Skip to content

Identity metrics clean up #62671

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 5 commits into from
Jul 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PR feedback
  • Loading branch information
JamesNK committed Jul 15, 2025
commit 1725d2655cc6cb9e25947d8bd97332fcabc3fdd2
14 changes: 7 additions & 7 deletions src/Identity/Core/src/SignInManagerMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal void CheckPasswordSignIn(string userType, SignInResult? result, Excepti
{ "aspnetcore.identity.user_type", userType },
};
AddSignInResult(ref tags, result);
AddExceptionTags(ref tags, exception);
AddErrorTag(ref tags, exception);

_checkPasswordCounter.Add(1, tags);
}
Expand All @@ -69,7 +69,7 @@ internal void AuthenticateSignIn(string userType, string authenticationScheme, S
};
AddIsPersistent(ref tags, isPersistent);
AddSignInResult(ref tags, result);
AddExceptionTags(ref tags, exception);
AddErrorTag(ref tags, exception);

_authenticateCounter.Add(1, tags);
}
Expand All @@ -87,7 +87,7 @@ internal void SignInUserPrincipal(string userType, string authenticationScheme,
{ "aspnetcore.identity.authentication_scheme", authenticationScheme },
};
AddIsPersistent(ref tags, isPersistent);
AddExceptionTags(ref tags, exception);
AddErrorTag(ref tags, exception);

_signInUserPrincipalCounter.Add(1, tags);
}
Expand All @@ -104,7 +104,7 @@ internal void SignOutUserPrincipal(string userType, string authenticationScheme,
{ "aspnetcore.identity.user_type", userType },
{ "aspnetcore.identity.authentication_scheme", authenticationScheme },
};
AddExceptionTags(ref tags, exception);
AddErrorTag(ref tags, exception);

_signOutUserPrincipalCounter.Add(1, tags);
}
Expand All @@ -121,7 +121,7 @@ internal void RememberTwoFactorClient(string userType, string authenticationSche
{ "aspnetcore.identity.user_type", userType },
{ "aspnetcore.identity.authentication_scheme", authenticationScheme }
};
AddExceptionTags(ref tags, exception);
AddErrorTag(ref tags, exception);

_rememberTwoFactorClientCounter.Add(1, tags);
}
Expand All @@ -138,7 +138,7 @@ internal void ForgetTwoFactorClient(string userType, string authenticationScheme
{ "aspnetcore.identity.user_type", userType },
{ "aspnetcore.identity.authentication_scheme", authenticationScheme }
};
AddExceptionTags(ref tags, exception);
AddErrorTag(ref tags, exception);

_forgetTwoFactorCounter.Add(1, tags);
}
Expand All @@ -164,7 +164,7 @@ private static void AddSignInResult(ref TagList tags, SignInResult? result)
}
}

private static void AddExceptionTags(ref TagList tags, Exception? exception)
private static void AddErrorTag(ref TagList tags, Exception? exception)
{
if (exception != null)
{
Expand Down
20 changes: 10 additions & 10 deletions src/Identity/Extensions.Core/src/UserManagerMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ internal sealed class UserManagerMetrics : IDisposable
public UserManagerMetrics(IMeterFactory meterFactory)
{
_meter = meterFactory.Create(MeterName);
_createCounter = _meter.CreateCounter<long>(CreateCounterName, "{create}", "The number of users created.");
_updateCounter = _meter.CreateCounter<long>(UpdateCounterName, "{update}", "The number of user updates.");
_deleteCounter = _meter.CreateCounter<long>(DeleteCounterName, "{delete}", "The number of users deleted.");
_createCounter = _meter.CreateCounter<long>(CreateCounterName, "{user}", "The number of users created.");
_updateCounter = _meter.CreateCounter<long>(UpdateCounterName, "{user}", "The number of users updated.");
_deleteCounter = _meter.CreateCounter<long>(DeleteCounterName, "{user}", "The number of users deleted.");
_checkPasswordCounter = _meter.CreateCounter<long>(CheckPasswordCounterName, "{check}", "The number of check password attempts. Only checks whether the password is valid and not whether the user account is in a state that can log in.");
_verifyTokenCounter = _meter.CreateCounter<long>(VerifyTokenCounterName, "{count}", "The number of token verification attempts.");
_generateTokenCounter = _meter.CreateCounter<long>(GenerateTokenCounterName, "{count}", "The number of token generation attempts.");
Expand All @@ -52,7 +52,7 @@ internal void CreateUser(string userType, IdentityResult? result, Exception? exc
{ "aspnetcore.identity.user_type", userType }
};
AddIdentityResultTags(ref tags, result);
AddExceptionTags(ref tags, exception, result: result);
AddErrorTag(ref tags, exception, result: result);

_createCounter.Add(1, tags);
}
Expand All @@ -70,7 +70,7 @@ internal void UpdateUser(string userType, IdentityResult? result, UserUpdateType
{ "aspnetcore.identity.user.update_type", GetUpdateType(updateType) },
};
AddIdentityResultTags(ref tags, result);
AddExceptionTags(ref tags, exception, result: result);
AddErrorTag(ref tags, exception, result: result);

_updateCounter.Add(1, tags);
}
Expand All @@ -87,7 +87,7 @@ internal void DeleteUser(string userType, IdentityResult? result, Exception? exc
{ "aspnetcore.identity.user_type", userType }
};
AddIdentityResultTags(ref tags, result);
AddExceptionTags(ref tags, exception, result: result);
AddErrorTag(ref tags, exception, result: result);

_deleteCounter.Add(1, tags);
}
Expand All @@ -107,7 +107,7 @@ internal void CheckPassword(string userType, bool? userMissing, PasswordVerifica
{
tags.Add("aspnetcore.identity.password_check_result", GetPasswordResult(result, passwordMissing: null, userMissing));
}
AddExceptionTags(ref tags, exception);
AddErrorTag(ref tags, exception);

_checkPasswordCounter.Add(1, tags);
}
Expand All @@ -128,7 +128,7 @@ internal void VerifyToken(string userType, bool? result, string purpose, Excepti
{
tags.Add("aspnetcore.identity.token_verified", result == true ? "success" : "failure");
}
AddExceptionTags(ref tags, exception);
AddErrorTag(ref tags, exception);

_verifyTokenCounter.Add(1, tags);
}
Expand All @@ -145,7 +145,7 @@ internal void GenerateToken(string userType, string purpose, Exception? exceptio
{ "aspnetcore.identity.user_type", userType },
{ "aspnetcore.identity.token_purpose", GetTokenPurpose(purpose) },
};
AddExceptionTags(ref tags, exception);
AddErrorTag(ref tags, exception);

_generateTokenCounter.Add(1, tags);
}
Expand Down Expand Up @@ -187,7 +187,7 @@ private static void AddIdentityResultTags(ref TagList tags, IdentityResult? resu
}
}

private static void AddExceptionTags(ref TagList tags, Exception? exception, IdentityResult? result = null)
private static void AddErrorTag(ref TagList tags, Exception? exception, IdentityResult? result = null)
{
var value = exception?.GetType().FullName ?? result?.Errors.FirstOrDefault()?.Code;
if (value != null)
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy