Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }