public void DefaultTracerFactory()
        {
            Assert.Equal(typeof(TracerFactoryBase), TracerFactoryBase.Default.GetType());
            Assert.Equal(typeof(ProxyTracer), TracerFactoryBase.Default.GetTracer(null).GetType());

            var newFactory = TracerFactory.Create(_ => { });

            TracerFactoryBase.SetDefault(newFactory);
            Assert.IsAssignableFrom <TracerFactory>(TracerFactoryBase.Default);
        }
        public void TraceFactory_UpdateDefault_CachedTracer()
        {
            var defaultTracer = TracerFactoryBase.Default.GetTracer(string.Empty);
            var noopSpan      = defaultTracer.StartSpan("foo");

            Assert.IsType <BlankSpan>(noopSpan);

            TracerFactoryBase.SetDefault(TracerFactory.Create(b => { }));
            var span = defaultTracer.StartSpan("foo");

            Assert.IsType <SpanSdk>(span);

            var newDefaultTracer = TracerFactoryBase.Default.GetTracer(string.Empty);

            Assert.NotSame(defaultTracer, newDefaultTracer);
            Assert.IsType <TracerSdk>(newDefaultTracer);
        }
        public void TraceFactory_SetDefault()
        {
            var factory = TracerFactory.Create(b => { });

            TracerFactoryBase.SetDefault(factory);

            var defaultTracer = TracerFactoryBase.Default.GetTracer(string.Empty);

            Assert.NotNull(defaultTracer);
            Assert.IsType <TracerSdk>(defaultTracer);

            Assert.NotSame(defaultTracer, TracerFactoryBase.Default.GetTracer("named tracerSdk"));

            var span = defaultTracer.StartSpan("foo");

            Assert.IsType <SpanSdk>(span);
        }
 public void TraceFactory_SetDefaultTwice_Throws()
 {
     TracerFactoryBase.SetDefault(TracerFactory.Create(b => { }));
     Assert.Throws <InvalidOperationException>(() => TracerFactoryBase.SetDefault(TracerFactory.Create(b => { })));
 }
 public void TraceFactory_SetDefaultNull()
 {
     Assert.Throws <ArgumentNullException>(() => TracerFactoryBase.SetDefault(null));
 }