Skip to content

Commit ea4ae7b

Browse files
Merge branch 'master' of https://github.com/snowflakedb/snowflake-connector-net into SNOW-834781-Remove-log4net
2 parents 7bb227b + a034791 commit ea4ae7b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Snowflake.Data/Core/RestRequester.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23
using Newtonsoft.Json;
34
using System.Net.Http;
45
using 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)

0 commit comments

Comments
 (0)