@@ -28,9 +28,9 @@ public async Task EventCountersAndMetricsValues()
28
28
// Arrange
29
29
var hostingEventSource = new HostingEventSource ( Guid . NewGuid ( ) . ToString ( ) ) ;
30
30
31
+ // requests-per-second isn't tested because the value can't be reliably tested because of time
31
32
using var eventListener = new TestCounterListener ( LoggerFactory , hostingEventSource . Name ,
32
33
[
33
- "requests-per-second" ,
34
34
"total-requests" ,
35
35
"current-requests" ,
36
36
"failed-requests"
@@ -40,7 +40,6 @@ public async Task EventCountersAndMetricsValues()
40
40
using CancellationTokenSource timeoutTokenSource = new CancellationTokenSource ( timeout ) ;
41
41
timeoutTokenSource . Token . Register ( ( ) => Logger . LogError ( "Timeout while waiting for counter value." ) ) ;
42
42
43
- var rpsValues = eventListener . GetCounterValues ( "requests-per-second" , timeoutTokenSource . Token ) . GetAsyncEnumerator ( ) ;
44
43
var totalRequestValues = eventListener . GetCounterValues ( "total-requests" , timeoutTokenSource . Token ) . GetAsyncEnumerator ( ) ;
45
44
var currentRequestValues = eventListener . GetCounterValues ( "current-requests" , timeoutTokenSource . Token ) . GetAsyncEnumerator ( ) ;
46
45
var failedRequestValues = eventListener . GetCounterValues ( "failed-requests" , timeoutTokenSource . Token ) . GetAsyncEnumerator ( ) ;
@@ -64,19 +63,22 @@ public async Task EventCountersAndMetricsValues()
64
63
using var requestDurationCollector2 = new MetricCollector < double > ( testMeterFactory2 , HostingMetrics . MeterName , "http.server.request.duration" ) ;
65
64
66
65
// Act/Assert 1
66
+ Logger . LogInformation ( "Act/Assert 1" ) ;
67
+ Logger . LogInformation ( nameof ( HostingApplication . CreateContext ) ) ;
68
+
67
69
var context1 = hostingApplication1 . CreateContext ( features1 ) ;
68
70
var context2 = hostingApplication2 . CreateContext ( features2 ) ;
69
71
70
72
await totalRequestValues . WaitForSumValueAsync ( 2 ) ;
71
- await rpsValues . WaitForValueAsync ( 2 ) ;
72
73
await currentRequestValues . WaitForValueAsync ( 2 ) ;
73
74
await failedRequestValues . WaitForValueAsync ( 0 ) ;
74
75
76
+ Logger . LogInformation ( nameof ( HostingApplication . DisposeContext ) ) ;
77
+
75
78
hostingApplication1 . DisposeContext ( context1 , null ) ;
76
79
hostingApplication2 . DisposeContext ( context2 , null ) ;
77
80
78
81
await totalRequestValues . WaitForSumValueAsync ( 2 ) ;
79
- await rpsValues . WaitForValueAsync ( 0 ) ;
80
82
await currentRequestValues . WaitForValueAsync ( 0 ) ;
81
83
await failedRequestValues . WaitForValueAsync ( 0 ) ;
82
84
@@ -92,22 +94,25 @@ public async Task EventCountersAndMetricsValues()
92
94
m => Assert . True ( m . Value > 0 ) ) ;
93
95
94
96
// Act/Assert 2
97
+ Logger . LogInformation ( "Act/Assert 2" ) ;
98
+ Logger . LogInformation ( nameof ( HostingApplication . CreateContext ) ) ;
99
+
95
100
context1 = hostingApplication1 . CreateContext ( features1 ) ;
96
101
context2 = hostingApplication2 . CreateContext ( features2 ) ;
97
102
98
103
await totalRequestValues . WaitForSumValueAsync ( 4 ) ;
99
- await rpsValues . WaitForValueAsync ( 2 ) ;
100
104
await currentRequestValues . WaitForValueAsync ( 2 ) ;
101
105
await failedRequestValues . WaitForValueAsync ( 0 ) ;
102
106
103
107
context1 . HttpContext . Response . StatusCode = StatusCodes . Status500InternalServerError ;
104
108
context2 . HttpContext . Response . StatusCode = StatusCodes . Status500InternalServerError ;
105
109
110
+ Logger . LogInformation ( nameof ( HostingApplication . DisposeContext ) ) ;
111
+
106
112
hostingApplication1 . DisposeContext ( context1 , null ) ;
107
113
hostingApplication2 . DisposeContext ( context2 , null ) ;
108
114
109
115
await totalRequestValues . WaitForSumValueAsync ( 4 ) ;
110
- await rpsValues . WaitForValueAsync ( 0 ) ;
111
116
await currentRequestValues . WaitForValueAsync ( 0 ) ;
112
117
await failedRequestValues . WaitForValueAsync ( 2 ) ;
113
118
0 commit comments