File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 11using System ;
2+ using System . Diagnostics ;
23using Newtonsoft . Json ;
34using System . Net . Http ;
45using System . Threading ;
@@ -107,27 +108,34 @@ protected virtual async Task<HttpResponseMessage> SendAsync(HttpRequestMessage m
107108 restRequestTimeout . Token ) )
108109 {
109110 HttpResponseMessage response = null ;
111+ logger . Debug ( $ "Executing: { sid } { message . Method } { message . RequestUri } HTTP/{ message . Version } ") ;
112+ var watch = new Stopwatch ( ) ;
110113 try
111114 {
112- logger . Debug ( $ "Executing: { sid } { message . Method } { message . RequestUri } HTTP/{ message . Version } ") ;
113-
115+ watch . Start ( ) ;
114116 response = await _HttpClient
115117 . SendAsync ( message , HttpCompletionOption . ResponseHeadersRead , linkedCts . Token )
116118 . ConfigureAwait ( false ) ;
119+ watch . Stop ( ) ;
117120 if ( ! response . IsSuccessStatusCode )
118121 {
119- logger . Error ( $ "Failed Response : { sid } { message . Method } { message . RequestUri } StatusCode: { ( int ) response . StatusCode } , ReasonPhrase: '{ response . ReasonPhrase } '") ;
122+ logger . Error ( $ "Failed response after { watch . ElapsedMilliseconds } ms : { sid } { message . Method } { message . RequestUri } StatusCode: { ( int ) response . StatusCode } , ReasonPhrase: '{ response . ReasonPhrase } '") ;
120123 }
121124 else
122125 {
123- logger . Debug ( $ "Succeeded Response : { sid } { message . Method } { message . RequestUri } ") ;
126+ logger . Debug ( $ "Succeeded response after { watch . ElapsedMilliseconds } ms : { sid } { message . Method } { message . RequestUri } ") ;
124127 }
125128 response . EnsureSuccessStatusCode ( ) ;
126129
127130 return response ;
128131 }
129132 catch ( Exception e )
130133 {
134+ if ( watch . IsRunning )
135+ {
136+ watch . Stop ( ) ;
137+ logger . Error ( $ "Response receiving interrupted by exception after { watch . ElapsedMilliseconds } ms. { sid } { message . Method } { message . RequestUri } ") ;
138+ }
131139 // Disposing of the response if not null now that we don't need it anymore
132140 response ? . Dispose ( ) ;
133141 if ( restRequestTimeout . IsCancellationRequested )
You can’t perform that action at this time.
0 commit comments