@@ -42,78 +42,83 @@ public UserManagerMetrics(IMeterFactory meterFactory)
4242
4343 internal void CreateUser ( string userType , IdentityResult ? result , Exception ? exception = null )
4444 {
45- if ( _createCounter . Enabled )
45+ if ( ! _createCounter . Enabled )
4646 {
47- var tags = new TagList
48- {
49- { "aspnetcore.identity.user_type" , userType }
50- } ;
51- AddIdentityResultTags ( ref tags , result ) ;
52- AddExceptionTags ( ref tags , exception ) ;
53-
54- _createCounter . Add ( 1 , tags ) ;
47+ return ;
5548 }
56- }
5749
58- private static void AddExceptionTags ( ref TagList tags , Exception ? exception )
59- {
60- if ( exception != null )
50+ var tags = new TagList
6151 {
62- tags . Add ( "error.type" , exception . GetType ( ) . FullName ! ) ;
63- }
52+ { "aspnetcore.identity.user_type" , userType }
53+ } ;
54+ AddIdentityResultTags ( ref tags , result ) ;
55+ AddExceptionTags ( ref tags , exception ) ;
56+
57+ _createCounter . Add ( 1 , tags ) ;
6458 }
6559
6660 internal void UpdateUser ( string userType , IdentityResult ? result , UserUpdateType updateType , Exception ? exception = null )
6761 {
68- if ( _updateCounter . Enabled )
62+ if ( ! _updateCounter . Enabled )
6963 {
70- var tags = new TagList
71- {
72- { "aspnetcore.identity.user_type" , userType } ,
73- { "aspnetcore.identity.user.update_type" , GetUpdateType ( updateType ) } ,
74- } ;
75- AddIdentityResultTags ( ref tags , result ) ;
76- AddExceptionTags ( ref tags , exception ) ;
77-
78- _updateCounter . Add ( 1 , tags ) ;
64+ return ;
7965 }
66+
67+ var tags = new TagList
68+ {
69+ { "aspnetcore.identity.user_type" , userType } ,
70+ { "aspnetcore.identity.user.update_type" , GetUpdateType ( updateType ) } ,
71+ } ;
72+ AddIdentityResultTags ( ref tags , result ) ;
73+ AddExceptionTags ( ref tags , exception ) ;
74+
75+ _updateCounter . Add ( 1 , tags ) ;
8076 }
8177
8278 internal void DeleteUser ( string userType , IdentityResult ? result , Exception ? exception = null )
8379 {
84- if ( _deleteCounter . Enabled )
80+ if ( ! _deleteCounter . Enabled )
8581 {
86- var tags = new TagList
87- {
88- { "aspnetcore.identity.user_type" , userType }
89- } ;
90- AddIdentityResultTags ( ref tags , result ) ;
91- AddExceptionTags ( ref tags , exception ) ;
92-
93- _deleteCounter . Add ( 1 , tags ) ;
82+ return ;
9483 }
84+
85+ var tags = new TagList
86+ {
87+ { "aspnetcore.identity.user_type" , userType }
88+ } ;
89+ AddIdentityResultTags ( ref tags , result ) ;
90+ AddExceptionTags ( ref tags , exception ) ;
91+
92+ _deleteCounter . Add ( 1 , tags ) ;
9593 }
9694
9795 internal void CheckPassword ( string userType , bool ? userMissing , PasswordVerificationResult ? result , Exception ? exception = null )
9896 {
99- if ( _checkPasswordCounter . Enabled )
97+ if ( ! _checkPasswordCounter . Enabled )
10098 {
101- var tags = new TagList
102- {
103- { "aspnetcore.identity.user_type" , userType } ,
104- } ;
105- if ( userMissing != null || result != null )
106- {
107- tags . Add ( "aspnetcore.identity.user.password_result" , GetPasswordResult ( result , passwordMissing : null , userMissing ) ) ;
108- }
109- AddExceptionTags ( ref tags , exception ) ;
110-
111- _checkPasswordCounter . Add ( 1 , tags ) ;
99+ return ;
112100 }
101+
102+ var tags = new TagList
103+ {
104+ { "aspnetcore.identity.user_type" , userType } ,
105+ } ;
106+ if ( userMissing != null || result != null )
107+ {
108+ tags . Add ( "aspnetcore.identity.user.password_result" , GetPasswordResult ( result , passwordMissing : null , userMissing ) ) ;
109+ }
110+ AddExceptionTags ( ref tags , exception ) ;
111+
112+ _checkPasswordCounter . Add ( 1 , tags ) ;
113113 }
114114
115115 internal void VerifyToken ( string userType , bool ? result , string purpose , Exception ? exception = null )
116116 {
117+ if ( ! _verifyTokenCounter . Enabled )
118+ {
119+ return ;
120+ }
121+
117122 var tags = new TagList
118123 {
119124 { "aspnetcore.identity.user_type" , userType } ,
@@ -130,6 +135,11 @@ internal void VerifyToken(string userType, bool? result, string purpose, Excepti
130135
131136 internal void GenerateToken ( string userType , string purpose , Exception ? exception = null )
132137 {
138+ if ( ! _generateTokenCounter . Enabled )
139+ {
140+ return ;
141+ }
142+
133143 var tags = new TagList
134144 {
135145 { "aspnetcore.identity.user_type" , userType } ,
@@ -177,6 +187,14 @@ private static void AddIdentityResultTags(ref TagList tags, IdentityResult? resu
177187 }
178188 }
179189
190+ private static void AddExceptionTags ( ref TagList tags , Exception ? exception )
191+ {
192+ if ( exception != null )
193+ {
194+ tags . Add ( "error.type" , exception . GetType ( ) . FullName ! ) ;
195+ }
196+ }
197+
180198 private static string GetPasswordResult ( PasswordVerificationResult ? result , bool ? passwordMissing , bool ? userMissing )
181199 {
182200 return ( result , passwordMissing ?? false , userMissing ?? false ) switch
0 commit comments