public void SourceCanBeCreatedAfterInput() { var healthReporter = new Mock <IHealthReporter>(); var observer = new TestObserver(); var ActivityName = GetRandomName(); const string TestSourceName = "EventFlowTestActivitySource"; var sources = new List <ActivitySourceConfiguration>(new[] { new ActivitySourceConfiguration { ActivitySourceName = TestSourceName, CapturedEvents = CapturedActivityEvents.Stop } }); using (var input = new ActivitySourceInput(new ActivitySourceInputConfiguration { Sources = sources }, healthReporter.Object)) { input.Subscribe(observer); using (var activitySouce = new System.Diagnostics.ActivitySource("EventFlowTestActivitySource")) { var activity = activitySouce.StartActivity(ActivityName); activity.Stop(); } } healthReporter.VerifyNoOtherCalls(); Assert.True(observer.Completed); Assert.Null(observer.Error); var observed = observer.Data.ToArray(); var e = Assert.Single(observed); Assert.Equal(ActivityName, e.Payload["Name"]); }
/// <summary> /// Dispose will unregister this <see cref="ActivityListener"/> object from listeneing to <see cref="Activity"/> events. /// </summary> public void Dispose() => ActivitySource.DetachListener(this);