public void CheckForceFlushExport(int timeout) { using var exporter = new TestActivityExporter(); using var processor = new BatchExportActivityProcessor( exporter, maxQueueSize: 3, maxExportBatchSize: 3, exporterTimeoutMilliseconds: 30000); processor.OnEnd(new Activity("start1")); processor.OnEnd(new Activity("start2")); Assert.Equal(0, processor.ProcessedCount); // waiting to see if time is triggering the exporter Thread.Sleep(1_000); Assert.Empty(exporter.Exported); // forcing flush processor.ForceFlush(timeout); if (timeout == 0) { // ForceFlush(0) will trigger flush and return immediately, so let's sleep for a while Thread.Sleep(1_000); } Assert.Equal(2, exporter.Exported.Count); Assert.Equal(2, processor.ProcessedCount); Assert.Equal(2, processor.ReceivedCount); Assert.Equal(0, processor.DroppedCount); }
public void CheckShutdownExport(int timeout) { using var exporter = new TestActivityExporter(); using var processor = new BatchExportActivityProcessor( exporter, maxQueueSize: 3, maxExportBatchSize: 3, exporterTimeoutMilliseconds: 30000); processor.OnEnd(new Activity("start")); processor.Shutdown(timeout); if (timeout == 0) { // ForceFlush(0) will trigger flush and return immediately, so let's sleep for a while Thread.Sleep(1_000); } Assert.Single(exporter.Exported); Assert.Equal(1, processor.ProcessedCount); Assert.Equal(1, processor.ReceivedCount); Assert.Equal(0, processor.DroppedCount); }