|
6 | 6 | using System.Diagnostics.Metrics; |
7 | 7 | using System.Linq; |
8 | 8 | using System.Threading.Tasks; |
| 9 | +using Microsoft.AspNetCore.Http; |
9 | 10 | using Microsoft.Extensions.Internal; |
10 | 11 | using static Microsoft.AspNetCore.Identity.UserManagerMetrics; |
11 | 12 |
|
@@ -33,12 +34,39 @@ internal sealed class UserManagerMetrics : IDisposable |
33 | 34 | public UserManagerMetrics(IMeterFactory meterFactory) |
34 | 35 | { |
35 | 36 | _meter = meterFactory.Create(MeterName); |
36 | | - _createDuration = _meter.CreateHistogram<double>(CreateDurationName, "s", "The duration of user creation operations."); |
37 | | - _updateDuration = _meter.CreateHistogram<double>(UpdateDurationName, "s", "The duration of user update operations."); |
38 | | - _deleteDuration = _meter.CreateHistogram<double>(DeleteDurationName, "s", "The duration of user deletion operations."); |
39 | | - _checkPasswordAttemptsCounter = _meter.CreateCounter<long>(CheckPasswordAttemptsCounterName, "{attempt}", "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."); |
40 | | - _verifyTokenAttemptsCounter = _meter.CreateCounter<long>(VerifyTokenAttemptsCounterName, "{attempt}", "The number of token verification attempts."); |
41 | | - _generateTokensCounter = _meter.CreateCounter<long>(GenerateTokensCounterName, "{count}", "The number of token generations."); |
| 37 | + |
| 38 | + _createDuration = _meter.CreateHistogram<double>( |
| 39 | + CreateDurationName, |
| 40 | + unit: "s", |
| 41 | + description: "The duration of user creation operations.", |
| 42 | + advice: new() { HistogramBucketBoundaries = MetricsConstants.ShortSecondsBucketBoundaries }); |
| 43 | + |
| 44 | + _updateDuration = _meter.CreateHistogram<double>( |
| 45 | + UpdateDurationName, |
| 46 | + unit: "s", |
| 47 | + description: "The duration of user update operations.", |
| 48 | + advice: new() { HistogramBucketBoundaries = MetricsConstants.ShortSecondsBucketBoundaries }); |
| 49 | + |
| 50 | + _deleteDuration = _meter.CreateHistogram<double>( |
| 51 | + DeleteDurationName, |
| 52 | + unit: "s", |
| 53 | + description: "The duration of user deletion operations.", |
| 54 | + advice: new() { HistogramBucketBoundaries = MetricsConstants.ShortSecondsBucketBoundaries }); |
| 55 | + |
| 56 | + _checkPasswordAttemptsCounter = _meter.CreateCounter<long>( |
| 57 | + CheckPasswordAttemptsCounterName, |
| 58 | + unit: "{attempt}", |
| 59 | + description: "The total 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."); |
| 60 | + |
| 61 | + _verifyTokenAttemptsCounter = _meter.CreateCounter<long>( |
| 62 | + VerifyTokenAttemptsCounterName, |
| 63 | + unit: "{attempt}", |
| 64 | + description: "The total number of token verification attempts."); |
| 65 | + |
| 66 | + _generateTokensCounter = _meter.CreateCounter<long>( |
| 67 | + GenerateTokensCounterName, |
| 68 | + unit: "{count}", |
| 69 | + description: "The total number of token generations."); |
42 | 70 | } |
43 | 71 |
|
44 | 72 | internal void CreateUser(string userType, IdentityResult? result, long startTimestamp, Exception? exception = null) |
|
0 commit comments