@@ -91,7 +91,7 @@ public void SendAsync_ExpectedDiagnosticSourceLogging()
9191 diagnosticListenerObserver . Enable ( s => ! s . Contains ( "HttpRequestOut" ) ) ;
9292 using ( var client = new HttpClient ( ) )
9393 {
94- var response = client . GetAsync ( Configuration . Http . RemoteEchoServer ) . Result ;
94+ client . GetAsync ( Configuration . Http . RemoteEchoServer ) . Result . Dispose ( ) ;
9595 }
9696
9797 Assert . True ( requestLogged , "Request was not logged." ) ;
@@ -150,10 +150,11 @@ public void SendAsync_ExpectedDiagnosticSourceNoLogging()
150150 {
151151 Task < List < string > > requestLines = LoopbackServer . AcceptSocketAsync ( server ,
152152 ( s , stream , reader , writer ) => LoopbackServer . ReadWriteAcceptedAsync ( s , reader , writer ) ) ;
153- Task response = client . GetAsync ( url ) ;
153+ Task < HttpResponseMessage > response = client . GetAsync ( url ) ;
154154 await Task . WhenAll ( response , requestLines ) ;
155155
156156 AssertNoHeadersAreInjected ( requestLines . Result ) ;
157+ response . Result . Dispose ( ) ;
157158 } ) . Wait ( ) ;
158159 }
159160
@@ -303,7 +304,6 @@ public void SendAsync_ExpectedDiagnosticCancelledLogging()
303304
304305 [ OuterLoop ] // TODO: Issue #11345
305306 [ Fact ]
306- [ ActiveIssue ( 19689 ) ]
307307 public void SendAsync_ExpectedDiagnosticSourceActivityLogging ( )
308308 {
309309 RemoteInvoke ( ( ) =>
@@ -351,17 +351,18 @@ public void SendAsync_ExpectedDiagnosticSourceActivityLogging()
351351
352352 using ( DiagnosticListener . AllListeners . Subscribe ( diagnosticListenerObserver ) )
353353 {
354- diagnosticListenerObserver . Enable ( ) ;
354+ diagnosticListenerObserver . Enable ( s => s . Contains ( "HttpRequestOut" ) ) ;
355355 using ( var client = new HttpClient ( ) )
356356 {
357357 LoopbackServer . CreateServerAsync ( async ( server , url ) =>
358358 {
359359 Task < List < string > > requestLines = LoopbackServer . AcceptSocketAsync ( server ,
360360 ( s , stream , reader , writer ) => LoopbackServer . ReadWriteAcceptedAsync ( s , reader , writer ) ) ;
361- Task response = client . GetAsync ( url ) ;
361+ Task < HttpResponseMessage > response = client . GetAsync ( url ) ;
362362 await Task . WhenAll ( response , requestLines ) ;
363363
364364 AssertHeadersAreInjected ( requestLines . Result , parentActivity ) ;
365+ response . Result . Dispose ( ) ;
365366 } ) . Wait ( ) ;
366367 }
367368
@@ -407,7 +408,7 @@ public void SendAsync_ExpectedDiagnosticSourceUrlFilteredActivityLogging()
407408 } ) ;
408409 using ( var client = new HttpClient ( ) )
409410 {
410- var response = client . GetAsync ( Configuration . Http . RemoteEchoServer ) . Result ;
411+ client . GetAsync ( Configuration . Http . RemoteEchoServer ) . Result . Dispose ( ) ;
411412 }
412413 Assert . False ( activityStartLogged , "HttpRequestOut.Start was logged while URL disabled." ) ;
413414 // Poll with a timeout since logging response is not synchronized with returning a response.
@@ -465,6 +466,45 @@ public void SendAsync_ExpectedDiagnosticExceptionActivityLogging()
465466 } ) . Dispose ( ) ;
466467 }
467468
469+ [ OuterLoop ] // TODO: Issue #11345
470+ [ Fact ]
471+ public void SendAsync_ExpectedDiagnosticSourceNewAndDeprecatedEventsLogging ( )
472+ {
473+ RemoteInvoke ( ( ) =>
474+ {
475+ bool requestLogged = false ;
476+ bool responseLogged = false ;
477+ bool activityStartLogged = false ;
478+ bool activityStopLogged = false ;
479+
480+ var diagnosticListenerObserver = new FakeDiagnosticListenerObserver ( kvp =>
481+ {
482+ if ( kvp . Key . Equals ( "System.Net.Http.Request" ) ) { requestLogged = true ; }
483+ else if ( kvp . Key . Equals ( "System.Net.Http.Response" ) ) { responseLogged = true ; }
484+ else if ( kvp . Key . Equals ( "System.Net.Http.HttpRequestOut.Start" ) ) { activityStartLogged = true ; }
485+ else if ( kvp . Key . Equals ( "System.Net.Http.HttpRequestOut.Stop" ) ) { activityStopLogged = true ; }
486+ } ) ;
487+
488+ using ( DiagnosticListener . AllListeners . Subscribe ( diagnosticListenerObserver ) )
489+ {
490+ diagnosticListenerObserver . Enable ( ) ;
491+ using ( var client = new HttpClient ( ) )
492+ {
493+ client . GetAsync ( Configuration . Http . RemoteEchoServer ) . Result . Dispose ( ) ;
494+ }
495+
496+ Assert . True ( activityStartLogged , "HttpRequestOut.Start was not logged." ) ;
497+ Assert . True ( requestLogged , "Request was not logged." ) ;
498+ // Poll with a timeout since logging response is not synchronized with returning a response.
499+ WaitForTrue ( ( ) => activityStopLogged , TimeSpan . FromSeconds ( 1 ) , "HttpRequestOut.Stop was not logged within 1 second timeout." ) ;
500+ Assert . True ( responseLogged , "Response was not logged." ) ;
501+ diagnosticListenerObserver . Disable ( ) ;
502+ }
503+
504+ return SuccessExitCode ;
505+ } ) . Dispose ( ) ;
506+ }
507+
468508 [ OuterLoop ] // TODO: Issue #11345
469509 [ Fact ]
470510 public void SendAsync_ExpectedDiagnosticExceptionOnlyActivityLogging ( )
@@ -527,7 +567,7 @@ public void SendAsync_ExpectedDiagnosticStopOnlyActivityLogging()
527567 diagnosticListenerObserver . Enable ( s => s . Equals ( "System.Net.Http.HttpRequestOut" ) ) ;
528568 using ( var client = new HttpClient ( ) )
529569 {
530- var response = client . GetAsync ( Configuration . Http . RemoteEchoServer ) . Result ;
570+ client . GetAsync ( Configuration . Http . RemoteEchoServer ) . Result . Dispose ( ) ;
531571 }
532572 // Poll with a timeout since logging response is not synchronized with returning a response.
533573 WaitForTrue ( ( ) => activityStopLogged , TimeSpan . FromSeconds ( 1 ) ,
0 commit comments