Skip to content

Commit e0ab809

Browse files
SNOW-2115047 Log http calls time
1 parent f2d4996 commit e0ab809

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Snowflake.Data/Core/RestRequester.cs

Lines changed: 6 additions & 3 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;
@@ -110,17 +111,19 @@ protected virtual async Task<HttpResponseMessage> SendAsync(HttpRequestMessage m
110111
try
111112
{
112113
logger.Debug($"Executing: {sid} {message.Method} {message.RequestUri} HTTP/{message.Version}");
113-
114+
var watch = new Stopwatch();
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

0 commit comments

Comments
 (0)