public void GetDistributedTrace() { var automaticTracer = new AutomaticTracer(); automaticTracer.GetDistributedTrace().Should().BeNull(); using (var scope = Tracer.Instance.StartActive("Test")) { var spanContext = SpanContextPropagator.Instance.Extract(automaticTracer.GetDistributedTrace()); spanContext.Should().NotBeNull(); spanContext.TraceId.Should().Be(scope.Span.TraceId); spanContext.SpanId.Should().Be(scope.Span.SpanId); } automaticTracer.GetDistributedTrace().Should().BeNull(); }
public void GetSpanContext_NoChild() { var automaticTracer = new AutomaticTracer(); automaticTracer.GetDistributedTrace().Should().BeNull(); automaticTracer.SetDistributedTrace(new SpanContext(1, 2)); ((IDistributedTracer)automaticTracer).GetSpanContext().Should().BeNull("automatic tracer shouldn't read the distributed trace unless there is a child tracer"); }
public void GetSpanContext() { var automaticTracer = new AutomaticTracer(); automaticTracer.Register(Mock.Of <ICommonTracer>()); automaticTracer.GetDistributedTrace().Should().BeNull(); var expectedSpanContext = new SpanContext(1, 2, SamplingPriorityValues.UserKeep, "Service", "Origin"); automaticTracer.SetDistributedTrace(expectedSpanContext); var actualSpanContext = ((IDistributedTracer)automaticTracer).GetSpanContext(); actualSpanContext.Should().BeEquivalentTo(expectedSpanContext); }