public void TracerBuilder_ValidArgs()
        {
            var builder = new TracerBuilder();

            bool processorFactoryCalled = false;
            bool collectorFactoryCalled = true;

            var sampler      = new ProbabilitySampler(0.1);
            var exporter     = new TestExporter(_ => { });
            var options      = new TracerConfiguration(1, 1, 1);
            var binaryFormat = new BinaryFormat();
            var textFormat   = new TraceContextFormat();

            builder
            .SetSampler(sampler)
            .AddProcessorPipeline(p => p
                                  .SetExporter(exporter)
                                  .SetExportingProcessor(e =>
            {
                processorFactoryCalled = true;
                Assert.Same(e, exporter);
                return(new SimpleSpanProcessor(e));
            }))
            .SetTracerOptions(options)
            .SetBinaryFormat(binaryFormat)
            .SetTextFormat(textFormat)
            .AddCollector(t =>
            {
                Assert.NotNull(t);
                return(new TestCollector(t));
            });

            Assert.Same(sampler, builder.Sampler);

            Assert.NotNull(builder.ProcessingPipelines);
            Assert.Single(builder.ProcessingPipelines);
            Assert.Same(exporter, builder.ProcessingPipelines[0].Exporter);

            Assert.NotNull(builder.ProcessingPipelines[0].Build());
            Assert.True(processorFactoryCalled);

            Assert.Same(options, builder.TracerConfigurationOptions);
            Assert.Same(binaryFormat, builder.BinaryFormat);
            Assert.Same(textFormat, builder.TextFormat);
            Assert.Single(builder.CollectorFactories);

            var collectorFactory = builder.CollectorFactories.Single();

            Assert.Equal(nameof(TestCollector), collectorFactory.Name);
            Assert.Equal("semver:" + typeof(TestCollector).Assembly.GetName().Version, collectorFactory.Version);

            Assert.NotNull(collectorFactory.Factory);
            collectorFactory.Factory(new Tracer(new SimpleSpanProcessor(exporter), new AlwaysSampleSampler(), options, binaryFormat, textFormat,
                                                Resource.Empty));

            Assert.True(collectorFactoryCalled);
        }
        public void TracerBuilder_ValidArgs()
        {
            var builder = new TracerBuilder();

            bool processorFactoryCalled       = false;
            bool instrumentationFactoryCalled = true;

            var sampler  = new ProbabilitySampler(0.1);
            var exporter = new TestSpanExporter(_ => { });
            var options  = new TracerConfiguration(1, 1, 1);

            builder
            .SetSampler(sampler)
            .AddProcessorPipeline(p => p
                                  .SetExporter(exporter)
                                  .SetExportingProcessor(e =>
            {
                processorFactoryCalled = true;
                Assert.Same(e, exporter);
                return(new SimpleSpanProcessor(e));
            }))
            .SetTracerOptions(options)
            .AddInstrumentation(t =>
            {
                Assert.NotNull(t);
                return(new TestInstrumentation(t));
            });

            Assert.Same(sampler, builder.Sampler);

            Assert.NotNull(builder.ProcessingPipelines);
            Assert.Single(builder.ProcessingPipelines);
            Assert.Same(exporter, builder.ProcessingPipelines[0].Exporter);

            Assert.NotNull(builder.ProcessingPipelines[0].Build());
            Assert.True(processorFactoryCalled);

            Assert.Same(options, builder.TracerConfigurationOptions);
            Assert.Single(builder.InstrumentationFactories);

            var instrumentationFactory = builder.InstrumentationFactories.Single();

            Assert.Equal(nameof(TestInstrumentation), instrumentationFactory.Name);
            Assert.Equal("semver:" + typeof(TestInstrumentation).Assembly.GetName().Version, instrumentationFactory.Version);

            Assert.NotNull(instrumentationFactory.Factory);
            instrumentationFactory.Factory(new TracerSdk(new SimpleSpanProcessor(exporter), new AlwaysOnSampler(), options, Resource.Empty));

            Assert.True(instrumentationFactoryCalled);
        }