@@ -104,6 +104,7 @@ public async Task RejectsConnectionsWhenLimitReached()
104
104
{
105
105
var testMeterFactory = new TestMeterFactory ( ) ;
106
106
using var rejectedConnections = new MetricCollector < long > ( testMeterFactory , "Microsoft.AspNetCore.Server.Kestrel" , "kestrel.rejected_connections" ) ;
107
+ using var connectionDuration = new MetricCollector < double > ( testMeterFactory , "Microsoft.AspNetCore.Server.Kestrel" , "kestrel.connection.duration" ) ;
107
108
108
109
const int max = 10 ;
109
110
var requestTcs = new TaskCompletionSource ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
@@ -149,6 +150,30 @@ public async Task RejectsConnectionsWhenLimitReached()
149
150
}
150
151
}
151
152
153
+ var measurements = connectionDuration . GetMeasurementSnapshot ( ) ;
154
+
155
+ Assert . Collection ( measurements ,
156
+ m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
157
+ m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
158
+ m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
159
+ m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
160
+ m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
161
+ m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
162
+ m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
163
+ m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
164
+ m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
165
+ m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
166
+ m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
167
+ m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
168
+ m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
169
+ m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
170
+ m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
171
+ m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
172
+ m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
173
+ m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
174
+ m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
175
+ m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ) ;
176
+
152
177
static void AssertCounter ( CollectedMeasurement < long > measurement ) => Assert . Equal ( 1 , measurement . Value ) ;
153
178
}
154
179
0 commit comments