Example #1
0
        public void TestSetup()
        {
            observedSpan = null;

            sender = Substitute.For <ISpanSender>();
            sender.When(s => s.Send(Arg.Any <ISpan>())).Do(info => observedSpan = info.Arg <ISpan>());

            settings       = new TracerSettings(sender);
            parentContext  = new TraceContext(Guid.NewGuid(), Guid.NewGuid());
            currentContext = new TraceContext(parentContext.TraceId, Guid.NewGuid());
            contextScope   = Substitute.For <IDisposable>();

            builder = new SpanBuilder(settings, contextScope, currentContext, parentContext);
        }
Example #2
0
        public void Dispose_should_dispose_trace_context_scope_even_when_sender_fails()
        {
            sender
            .When(s => s.Send(Arg.Any <ISpan>()))
            .Throw(new Exception("I fail."));

            try
            {
                builder.Dispose();
            }
            catch (Exception error)
            {
                Console.Out.WriteLine(error);
            }

            contextScope.Received(1).Dispose();
        }