|
4 | 4 | using System; |
5 | 5 | using System.Buffers; |
6 | 6 | using System.Collections.Generic; |
| 7 | +using System.Diagnostics; |
7 | 8 | using System.IO; |
8 | 9 | using System.IO.Pipelines; |
9 | 10 | using System.Linq; |
@@ -2078,7 +2079,7 @@ public async Task WriteThatIsDisposedBeforeCompleteReturns404() |
2078 | 2079 | TransportMaxBufferSize = 13, |
2079 | 2080 | ApplicationMaxBufferSize = 13 |
2080 | 2081 | }; |
2081 | | - |
| 2082 | + |
2082 | 2083 | var connection = manager.CreateConnection(options); |
2083 | 2084 | connection.TransportType = HttpTransportType.LongPolling; |
2084 | 2085 |
|
@@ -2594,6 +2595,53 @@ public async Task DisposeLongPollingConnectionDisposesServiceScope() |
2594 | 2595 | } |
2595 | 2596 | } |
2596 | 2597 |
|
| 2598 | + private class TestActivityFeature : IHttpActivityFeature |
| 2599 | + { |
| 2600 | + public TestActivityFeature(Activity activity) |
| 2601 | + { |
| 2602 | + Activity = activity; |
| 2603 | + } |
| 2604 | + |
| 2605 | + public Activity Activity { get; set; } |
| 2606 | + } |
| 2607 | + |
| 2608 | + [Fact] |
| 2609 | + public async Task LongRunningActivityTagSetOnExecuteAsync() |
| 2610 | + { |
| 2611 | + using (StartVerifiableLog()) |
| 2612 | + { |
| 2613 | + var manager = CreateConnectionManager(LoggerFactory); |
| 2614 | + var connection = manager.CreateConnection(); |
| 2615 | + connection.TransportType = HttpTransportType.ServerSentEvents; |
| 2616 | + |
| 2617 | + var dispatcher = new HttpConnectionDispatcher(manager, LoggerFactory); |
| 2618 | + var services = new ServiceCollection(); |
| 2619 | + services.AddSingleton<NeverEndingConnectionHandler>(); |
| 2620 | + var context = MakeRequest("/foo", connection, services); |
| 2621 | + var cts = new CancellationTokenSource(); |
| 2622 | + context.RequestAborted = cts.Token; |
| 2623 | + SetTransport(context, HttpTransportType.ServerSentEvents); |
| 2624 | + |
| 2625 | + var builder = new ConnectionBuilder(services.BuildServiceProvider()); |
| 2626 | + builder.UseConnectionHandler<NeverEndingConnectionHandler>(); |
| 2627 | + var app = builder.Build(); |
| 2628 | + |
| 2629 | + var activityFeature = new TestActivityFeature(new Activity("name")); |
| 2630 | + activityFeature.Activity.Start(); |
| 2631 | + context.Features.Set<IHttpActivityFeature>(activityFeature); |
| 2632 | + |
| 2633 | + _ = dispatcher.ExecuteAsync(context, new HttpConnectionDispatcherOptions(), app); |
| 2634 | + |
| 2635 | + Assert.Equal("true", Activity.Current.GetTagItem("http.long_running")); |
| 2636 | + |
| 2637 | + connection.Transport.Output.Complete(); |
| 2638 | + |
| 2639 | + await connection.ConnectionClosed.WaitForCancellationAsync().DefaultTimeout(); |
| 2640 | + |
| 2641 | + activityFeature.Activity.Dispose(); |
| 2642 | + } |
| 2643 | + } |
| 2644 | + |
2597 | 2645 | private static async Task CheckTransportSupported(HttpTransportType supportedTransports, HttpTransportType transportType, int status, ILoggerFactory loggerFactory) |
2598 | 2646 | { |
2599 | 2647 | var manager = CreateConnectionManager(loggerFactory); |
|
0 commit comments