Enable Http2.0 tests for Http telemetry (#40763)
authorMiha Zupan <mihazupan.zupan1@gmail.com>
Thu, 13 Aug 2020 15:28:05 +0000 (17:28 +0200)
committerGitHub <noreply@github.com>
Thu, 13 Aug 2020 15:28:05 +0000 (17:28 +0200)
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Stream.cs
src/libraries/System.Net.Http/tests/FunctionalTests/TelemetryTest.cs

index c019cd4..bc65f04 100644 (file)
@@ -352,7 +352,11 @@ namespace System.Net.Http
                     _creditWaiter = null;
                 }
 
-                if (HttpTelemetry.Log.IsEnabled()) _request.OnStopped();
+                if (HttpTelemetry.Log.IsEnabled())
+                {
+                    bool aborted = _requestCompletionState == StreamCompletionState.Failed || _responseCompletionState == StreamCompletionState.Failed;
+                    _request.OnStopped(aborted);
+                }
             }
 
             private void Cancel()
index 89dc6ac..ea9df9b 100644 (file)
@@ -20,6 +20,8 @@ namespace System.Net.Http.Functional.Tests
 
     public sealed class TelemetryTest_Http20 : TelemetryTest
     {
+        protected override Version UseVersion => HttpVersion.Version20;
+
         public TelemetryTest_Http20(ITestOutputHelper output) : base(output) { }
     }
 
@@ -135,7 +137,7 @@ namespace System.Net.Http.Functional.Tests
             Assert.Equal("RequestStart", startEvent.EventName);
             Assert.Equal(6, startEvent.Payload.Count);
 
-            Assert.Equal("http", (string)startEvent.Payload[0]);
+            Assert.StartsWith("http", (string)startEvent.Payload[0]);
             Assert.NotEmpty((string)startEvent.Payload[1]); // host
             Assert.True(startEvent.Payload[2] is int port && port >= 0 && port <= 65535);
             Assert.NotEmpty((string)startEvent.Payload[3]); // pathAndQuery