public async Task ForceFlushReturnsCompletedTask() { var activityProcessor = new SimpleActivityProcessor(new TestActivityExporter(null)); var forceFlushTask = activityProcessor.ForceFlushAsync(CancellationToken.None); await forceFlushTask; Assert.True(forceFlushTask.IsCompleted); }
public async Task ShutdownTwice() { var activityProcessor = new SimpleActivityProcessor(new TestActivityExporter(null)); await activityProcessor.ShutdownAsync(CancellationToken.None).ConfigureAwait(false); // does not throw await activityProcessor.ShutdownAsync(CancellationToken.None).ConfigureAwait(false); }
internal ActivityProcessor Build() { this.Processors = new List <ActivityProcessor>(); ActivityProcessor exportingProcessor = null; // build or create default exporting processor if (this.lastProcessorFactory != null) { exportingProcessor = this.lastProcessorFactory.Invoke(this.Exporter); this.Processors.Add(exportingProcessor); } else if (this.Exporter != null) { // TODO: Make this BatchingActivityProcessor once its available. exportingProcessor = new SimpleActivityProcessor(this.Exporter); this.Processors.Add(exportingProcessor); } if (this.processorChain == null) { // if there is no chain, return exporting processor. if (exportingProcessor == null) { exportingProcessor = new NoopActivityProcessor(); this.Processors.Add(exportingProcessor); } return(exportingProcessor); } var next = exportingProcessor; // build chain from the end to the beginning for (int i = this.processorChain.Count - 1; i >= 0; i--) { next = this.processorChain[i].Invoke(next); this.Processors.Add(next); } // return the last processor in the chain - it will be called first return(this.Processors[this.Processors.Count - 1]); }