public void Trace_MultipleSpans()
        {
            string rootSpanName = EntryData.GetMessage(nameof(Trace_MultipleSpans), _testId);
            var    labels       = new Dictionary <string, string>
            {
                { "annotation-key", "annotation-value" }
            };

            var tracer = CreateSimpleManagedTracer(_grpcConsumer);

            using (tracer.StartSpan(rootSpanName))
            {
                BlockUntilClockTick();
                using (tracer.StartSpan("child-one"))
                {
                    tracer.SetStackTrace(TraceEntryData.CreateStackTrace());
                    BlockUntilClockTick();
                }
                using (tracer.StartSpan("child-two"))
                {
                    BlockUntilClockTick();
                    using (tracer.StartSpan("grandchild-one", StartSpanOptions.Create(SpanKind.RpcClient)))
                    {
                        BlockUntilClockTick();
                    }
                    using (tracer.StartSpan("grandchild-two"))
                    {
                        BlockUntilClockTick();
                        tracer.AnnotateSpan(labels);
                    }
                }
            }

            TraceProto trace = TraceEntryPolling.Default.GetTrace(rootSpanName, _startTime);

            Assert.NotNull(trace);
            Assert.Equal(5, trace.Spans.Count);

            TraceSpan root          = trace.Spans.First(s => s.Name.Equals(rootSpanName));
            TraceSpan childOne      = trace.Spans.First(s => s.Name.Equals("child-one"));
            TraceSpan childTwo      = trace.Spans.First(s => s.Name.Equals("child-two"));
            TraceSpan grandchildOne = trace.Spans.First(s => s.Name.Equals("grandchild-one"));
            TraceSpan grandchildTwo = trace.Spans.First(s => s.Name.Equals("grandchild-two"));

            Assert.Equal(root.SpanId, childOne.ParentSpanId);
            TraceEntryVerifiers.AssertContainsStackTrace(childOne,
                                                         nameof(TraceEntryData.CreateStackTrace), nameof(SimpleManagedTracerTest));

            Assert.Equal(root.SpanId, childTwo.ParentSpanId);

            Assert.Equal(childTwo.SpanId, grandchildOne.ParentSpanId);
            Assert.Equal(TraceSpan.Types.SpanKind.RpcClient, grandchildOne.Kind);

            Assert.Equal(childTwo.SpanId, grandchildTwo.ParentSpanId);
            Assert.Equal(TraceSpan.Types.SpanKind.Unspecified, grandchildTwo.Kind);
            TraceEntryVerifiers.AssertSpanLabelsExact(grandchildTwo, labels);
        }
        public async Task TraceOutGoing()
        {
            string googleUri = "https://google.com/";
            var    spanName  = EntryData.GetMessage(nameof(TraceOutGoing), _testId);

            await TraceOutGoingRequest(spanName, googleUri, false);

            var trace = TraceEntryPolling.Default.GetTrace(spanName, _startTime);

            TraceEntryVerifiers.AssertParentChildSpan(trace, spanName, googleUri);
            TraceEntryVerifiers.AssertSpanLabelsExact(
                trace.Spans.First(s => s.Name == googleUri), TraceEntryData.HttpGetSuccessLabels);
        }
        public async Task TraceOutGoing_HttpError()
        {
            string fakeUri  = "https://google.com/404";
            var    spanName = EntryData.GetMessage(nameof(TraceOutGoing_HttpError), _testId);

            await TraceOutGoingRequest(spanName, fakeUri, false);

            var trace = TraceEntryPolling.Default.GetTrace(spanName, _startTime);

            TraceEntryVerifiers.AssertParentChildSpan(trace, spanName, fakeUri);
            TraceEntryVerifiers.AssertSpanLabelsExact(trace.Spans.Where(s => s.Name == fakeUri).Single(),
                                                      new Dictionary <string, string>
            {
                { TraceLabels.HttpMethod, "GET" },
                { TraceLabels.HttpStatusCode, "404" }
            });
        }
        public void Trace_SimpleAnnotation()
        {
            string rootSpanName = EntryData.GetMessage(nameof(Trace_SimpleAnnotation), _testId);
            var    labels       = new Dictionary <string, string>
            {
                { "annotation-key", "annotation-value" },
                { "some-key", "some-value" }
            };

            var tracer = CreateSimpleManagedTracer(_grpcConsumer);

            using (tracer.StartSpan(rootSpanName))
            {
                BlockUntilClockTick();
                tracer.AnnotateSpan(labels);
            }

            TraceProto trace = TraceEntryPolling.Default.GetTrace(rootSpanName, _startTime);

            TraceEntryVerifiers.AssertSingleSpan(trace, rootSpanName);
            TraceEntryVerifiers.AssertSpanLabelsExact(trace.Spans.First(), labels);
        }