private static void DoProcess(object obj) { var threadIndex = (int)obj; KickOffEvent.Wait(); for (int i = 0; i < 10000; i++) { var result = Task.Run(async() => { var rootSpan = new StartClientTrace("root_" + threadIndex, isDebug: true); var cur = TraceContextPropagation.CurrentSpan; rootSpan.Span.Should().Be(cur); await CompleteOnThreadPool(); await CompleteWithinSpawnedTask(); await CompleteWithCustomThread(); rootSpan.Dispose(); cur = TraceContextPropagation.CurrentSpan; cur.Should().BeNull(); return(true); }).Result; if (!result) { break; } } Console.WriteLine("Thread {0} done", threadIndex); }
public async Task PushPop_pop_on_task() { var span = new StartClientTrace("span4", isDebug: true); // TraceContextPropagation.IsWithinTrace.Should().BeTrue(); var current = TraceContextPropagation.CurrentSpan; current.Should().Be(span.Span); await CompleteWithinSpawnedTask(); span.Dispose(); // TraceContextPropagation.IsWithinTrace.Should().BeFalse(); current = TraceContextPropagation.CurrentSpan; current.Should().BeNull(); }
public async Task PushPop_no_thread_switch() { var span = new StartClientTrace("span1", isDebug: true); // TraceContextPropagation.IsWithinTrace.Should().BeTrue(); var current = TraceContextPropagation.CurrentSpan; current.Should().Be(span.Span); await ImmediateRet(); span.Dispose(); // TraceContextPropagation.IsWithinTrace.Should().BeFalse(); current = TraceContextPropagation.CurrentSpan; current.Should().BeNull(); }