Skip to content

Commit 4316ff0

Browse files
committed
Logging and comment cleanup
1 parent d489a05 commit 4316ff0

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/Agent/NewRelic/Agent/Core/DataTransport/Client/NRHttpClient.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public NRHttpClient(IWebProxy proxy, IConfiguration configuration) : base(proxy)
2727
_timeout = TimeSpan.FromMilliseconds((int)configuration.CollectorTimeout);
2828
_httpMethod = configuration.PutForDataSend ? HttpMethod.Put : HttpMethod.Post;
2929

30-
// set the default timeout to "infinite", but specify the configured collector timeout as the actual timeout for SendAsync() calls
3130
var httpHandler = GetHttpHandler(proxy);
3231

3332
var httpClient = new HttpClient(httpHandler, true) { Timeout = _timeout };
@@ -44,9 +43,9 @@ private dynamic GetHttpHandler(IWebProxy proxy)
4443
var pooledConnectionLifetime = TimeSpan.FromMinutes(5); // an in-use connection will be closed and recycled after 5 minutes
4544
var pooledConnectionIdleTimeout = TimeSpan.FromMinutes(1); // a connection that is idle for 1 minute will be closed and recycled
4645

47-
Log.Info($"Creating a SocketsHttpHandler with PooledConnectionLifetime {pooledConnectionLifetime}, PooledConnectionIdleTimeout {pooledConnectionIdleTimeout} and ConnectTimeout {_timeout}");
46+
Log.Info("Creating a SocketsHttpHandler with PooledConnectionLifetime {ConnectionLifetime}, PooledConnectionIdleTimeout {ConnectionIdleTimeout} and ConnectTimeout {ConnectTimeout}", pooledConnectionLifetime, pooledConnectionIdleTimeout, _timeout);
4847

49-
// use reflection to create a SocketsHttpHandler instance and set the PooledConnectionLifetime to 1 minute
48+
// use reflection to create a SocketsHttpHandler instance and set the timeout values
5049
var assembly = Assembly.Load("System.Net.Http");
5150
var handlerType = assembly.GetType("System.Net.Http.SocketsHttpHandler");
5251
dynamic handler = Activator.CreateInstance(handlerType);
@@ -57,18 +56,18 @@ private dynamic GetHttpHandler(IWebProxy proxy)
5756

5857
handler.Proxy = proxy;
5958

60-
Log.Info("Current SocketsHttpHandler TLS Configuration (SocketsHttpHandler.SslOptions): {0}", handler.SslOptions.EnabledSslProtocols);
59+
Log.Info("Current SocketsHttpHandler TLS Configuration (SocketsHttpHandler.SslOptions): {SslOptions}", handler.SslOptions.EnabledSslProtocols);
6160
return handler;
6261
}
6362
catch (Exception e)
6463
{
65-
Log.Info(e, "Application is running .NET 6+ but an exception occurred trying to create SocketsHttpHandler. Falling back to HttpHandler.");
64+
Log.Info(e, "Application runtime is .NET 6+ but an exception occurred trying to create SocketsHttpHandler. Falling back to HttpHandler.");
6665
}
6766
}
6867

6968
// if the application is not running .NET 6 or later, use the default HttpClientHandler
70-
var httpClientHandler = new HttpClientHandler { Proxy = proxy };
71-
Log.Info("Current HttpClientHandler TLS Configuration (HttpClientHandler.SslProtocols): {0}", httpClientHandler.SslProtocols.ToString());
69+
var httpClientHandler = new HttpClientHandler { Proxy = proxy};
70+
Log.Info("Current HttpClientHandler TLS Configuration (HttpClientHandler.SslProtocols): {SslProtocols}", httpClientHandler.SslProtocols.ToString());
7271

7372
return httpClientHandler;
7473
}

0 commit comments

Comments
 (0)