Add additional trace to HttpConnectionPool (#66958)
authorNatalia Kondratyeva <knatalia@microsoft.com>
Wed, 13 Apr 2022 15:48:34 +0000 (17:48 +0200)
committerGitHub <noreply@github.com>
Wed, 13 Apr 2022 15:48:34 +0000 (08:48 -0700)
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs

index b5e9778ab54992e20ad45b59b677a4130d844529..3456e440faf6e68093e16f72312bc29c86f127ac 100644 (file)
@@ -478,6 +478,13 @@ namespace System.Net.Http
                 return;
             }
 
+            if (NetEventSource.Log.IsEnabled())
+            {
+                Trace($"Available HTTP/1.1 connections: {_availableHttp11Connections.Count}, Requests in the queue: {_http11RequestQueue.Count}, " +
+                    $"Pending HTTP/1.1 connections: {_pendingHttp11ConnectionCount}, Total associated HTTP/1.1 connections: {_associatedHttp11ConnectionCount}, " +
+                    $"Max HTTP/1.1 connection limit: {_maxHttp11Connections}.");
+            }
+
             // Determine if we can and should add a new connection to the pool.
             if (_availableHttp11Connections.Count == 0 &&                           // No available connections
                 _http11RequestQueue.Count > _pendingHttp11ConnectionCount &&        // More requests queued than pending connections
@@ -852,8 +859,10 @@ namespace System.Net.Http
                 {
                     quicConnection = await ConnectHelper.ConnectQuicAsync(request, Settings._quicImplementationProvider ?? QuicImplementationProviders.Default, new DnsEndPoint(authority.IdnHost, authority.Port), _sslOptionsHttp3!, cancellationToken).ConfigureAwait(false);
                 }
-                catch
+                catch (Exception e)
                 {
+                    if (NetEventSource.Log.IsEnabled()) Trace($"QUIC connection failed: {e}");
+
                     // Disables HTTP/3 until server announces it can handle it via Alt-Svc.
                     BlocklistAuthority(authority);
                     throw;
@@ -1575,7 +1584,7 @@ namespace System.Net.Http
 
         private void HandleHttp11ConnectionFailure(Exception e)
         {
-            if (NetEventSource.Log.IsEnabled()) Trace("HTTP/1.1 connection failed");
+            if (NetEventSource.Log.IsEnabled()) Trace($"HTTP/1.1 connection failed: {e}");
 
             lock (SyncObj)
             {
@@ -1594,7 +1603,7 @@ namespace System.Net.Http
 
         private void HandleHttp2ConnectionFailure(Exception e)
         {
-            if (NetEventSource.Log.IsEnabled()) Trace("HTTP2 connection failed");
+            if (NetEventSource.Log.IsEnabled()) Trace($"HTTP2 connection failed: {e}");
 
             lock (SyncObj)
             {