@@ -227,7 +227,7 @@ private async Task<string> GetStringAsyncCore(HttpRequestMessage request, Cancel
227
227
}
228
228
finally
229
229
{
230
- FinishSend ( cts , disposeCts , telemetryStarted , responseContentTelemetryStarted ) ;
230
+ FinishSend ( cts , disposeCts , response , telemetryStarted , responseContentTelemetryStarted ) ;
231
231
}
232
232
}
233
233
@@ -306,7 +306,7 @@ private async Task<byte[]> GetByteArrayAsyncCore(HttpRequestMessage request, Can
306
306
}
307
307
finally
308
308
{
309
- FinishSend ( cts , disposeCts , telemetryStarted , responseContentTelemetryStarted ) ;
309
+ FinishSend ( cts , disposeCts , response , telemetryStarted , responseContentTelemetryStarted ) ;
310
310
}
311
311
}
312
312
@@ -352,7 +352,7 @@ private async Task<Stream> GetStreamAsyncCore(HttpRequestMessage request, Cancel
352
352
}
353
353
finally
354
354
{
355
- FinishSend ( cts , disposeCts , telemetryStarted , responseContentTelemetryStarted : false ) ;
355
+ FinishSend ( cts , disposeCts , response , telemetryStarted , responseContentTelemetryStarted : false ) ;
356
356
}
357
357
}
358
358
@@ -496,7 +496,7 @@ public HttpResponseMessage Send(HttpRequestMessage request, HttpCompletionOption
496
496
}
497
497
finally
498
498
{
499
- FinishSend ( cts , disposeCts , telemetryStarted , responseContentTelemetryStarted ) ;
499
+ FinishSend ( cts , disposeCts , response , telemetryStarted , responseContentTelemetryStarted ) ;
500
500
}
501
501
}
502
502
@@ -551,7 +551,7 @@ async Task<HttpResponseMessage> Core(
551
551
}
552
552
finally
553
553
{
554
- FinishSend ( cts , disposeCts , telemetryStarted , responseContentTelemetryStarted ) ;
554
+ FinishSend ( cts , disposeCts , response , telemetryStarted , responseContentTelemetryStarted ) ;
555
555
}
556
556
}
557
557
}
@@ -642,7 +642,7 @@ private static bool StartSend(HttpRequestMessage request)
642
642
return false ;
643
643
}
644
644
645
- private static void FinishSend ( CancellationTokenSource cts , bool disposeCts , bool telemetryStarted , bool responseContentTelemetryStarted )
645
+ private static void FinishSend ( CancellationTokenSource cts , bool disposeCts , HttpResponseMessage ? response , bool telemetryStarted , bool responseContentTelemetryStarted )
646
646
{
647
647
// Log completion.
648
648
if ( HttpTelemetry . Log . IsEnabled ( ) && telemetryStarted )
@@ -652,7 +652,8 @@ private static void FinishSend(CancellationTokenSource cts, bool disposeCts, boo
652
652
HttpTelemetry . Log . ResponseContentStop ( ) ;
653
653
}
654
654
655
- HttpTelemetry . Log . RequestStop ( ) ;
655
+ int statusCode = response != null ? ( int ) response . StatusCode : - 1 ;
656
+ HttpTelemetry . Log . RequestStop ( statusCode ) ;
656
657
}
657
658
658
659
// Dispose of the CancellationTokenSource if it was created specially for this request
0 commit comments