@@ -117,9 +117,10 @@ public async Task FlushAsync_OnSocketWithCanceledPendingFlush_ReturnsResultWithI
117
117
[ Fact ]
118
118
public void AbortsTransportEvenAfterDispose ( )
119
119
{
120
+ var metricsTagsFeature = new TestConnectionMetricsTagsFeature ( ) ;
120
121
var mockConnectionContext = new Mock < ConnectionContext > ( ) ;
121
122
122
- var outputProducer = CreateOutputProducer ( connectionContext : mockConnectionContext . Object ) ;
123
+ var outputProducer = CreateOutputProducer ( connectionContext : mockConnectionContext . Object , metricsTagsFeature : metricsTagsFeature ) ;
123
124
124
125
outputProducer . Dispose ( ) ;
125
126
@@ -132,6 +133,8 @@ public void AbortsTransportEvenAfterDispose()
132
133
outputProducer . Abort ( null , ConnectionEndReason . AbortedByApplication ) ;
133
134
134
135
mockConnectionContext . Verify ( f => f . Abort ( null ) , Times . Once ( ) ) ;
136
+
137
+ Assert . Equal ( nameof ( ConnectionEndReason . AbortedByApplication ) , metricsTagsFeature . Tags . Single ( t => t . Key == KestrelMetrics . KestrelConnectionEndReason ) . Value ) ;
135
138
}
136
139
137
140
[ Fact ]
@@ -219,7 +222,8 @@ public void ReusesFakeMemory()
219
222
220
223
private TestHttpOutputProducer CreateOutputProducer (
221
224
PipeOptions pipeOptions = null ,
222
- ConnectionContext connectionContext = null )
225
+ ConnectionContext connectionContext = null ,
226
+ IConnectionMetricsTagsFeature metricsTagsFeature = null )
223
227
{
224
228
pipeOptions = pipeOptions ?? new PipeOptions ( ) ;
225
229
connectionContext = connectionContext ?? Mock . Of < ConnectionContext > ( ) ;
@@ -234,12 +238,17 @@ private TestHttpOutputProducer CreateOutputProducer(
234
238
serviceContext . Log ,
235
239
Mock . Of < ITimeoutControl > ( ) ,
236
240
Mock . Of < IHttpMinResponseDataRateFeature > ( ) ,
237
- Mock . Of < IConnectionMetricsTagsFeature > ( ) ,
241
+ metricsTagsFeature ?? new TestConnectionMetricsTagsFeature ( ) ,
238
242
Mock . Of < IHttpOutputAborter > ( ) ) ;
239
243
240
244
return socketOutput ;
241
245
}
242
246
247
+ private class TestConnectionMetricsTagsFeature : IConnectionMetricsTagsFeature
248
+ {
249
+ public ICollection < KeyValuePair < string , object > > Tags { get ; } = new List < KeyValuePair < string , object > > ( ) ;
250
+ }
251
+
243
252
private class TestHttpOutputProducer : Http1OutputProducer
244
253
{
245
254
public TestHttpOutputProducer ( Pipe pipe , string connectionId , ConnectionContext connectionContext , MemoryPool < byte > memoryPool , KestrelTrace log , ITimeoutControl timeoutControl , IHttpMinResponseDataRateFeature minResponseDataRateFeature , IConnectionMetricsTagsFeature metricsTagsFeature , IHttpOutputAborter outputAborter )
0 commit comments