public void CheckForceFlushExport(int timeout) { var exportedItems = new List <Activity>(); using var exporter = new InMemoryExporter <Activity>(exportedItems); using var processor = new SimpleActivityExportProcessor(exporter); var activity1 = new Activity("start1"); activity1.ActivityTraceFlags = ActivityTraceFlags.Recorded; var activity2 = new Activity("start2"); activity2.ActivityTraceFlags = ActivityTraceFlags.Recorded; processor.OnEnd(activity1); processor.OnEnd(activity2); // checking before force flush Assert.Equal(2, exportedItems.Count); // forcing flush processor.ForceFlush(timeout); Assert.Equal(2, exportedItems.Count); }
public void CheckExportedOnEnd() { var exportedItems = new List <Activity>(); using var exporter = new InMemoryExporter <Activity>(exportedItems); using var processor = new SimpleActivityExportProcessor(exporter); var activity1 = new Activity("start1"); activity1.ActivityTraceFlags = ActivityTraceFlags.Recorded; processor.OnEnd(activity1); Assert.Single(exportedItems); var activity2 = new Activity("start2"); activity2.ActivityTraceFlags = ActivityTraceFlags.Recorded; processor.OnEnd(activity2); Assert.Equal(2, exportedItems.Count); }
public void CheckExportForRecordingButNotSampledActivity() { var exportedItems = new List <Activity>(); using var exporter = new InMemoryExporter <Activity>(exportedItems); using var processor = new SimpleActivityExportProcessor(exporter); var activity = new Activity("start"); activity.ActivityTraceFlags = ActivityTraceFlags.None; processor.OnEnd(activity); Assert.Empty(exportedItems); }
public void CheckShutdownExport(int timeout) { var exportedItems = new List <Activity>(); using var exporter = new InMemoryExporter <Activity>(exportedItems); using var processor = new SimpleActivityExportProcessor(exporter); var activity = new Activity("start"); activity.ActivityTraceFlags = ActivityTraceFlags.Recorded; processor.OnEnd(activity); // checking before shutdown Assert.Single(exportedItems); processor.Shutdown(timeout); Assert.Single(exportedItems); }