コード例 #1
0
        public void CollectSpans()
        {
            SetupSpanCollector();

            var testSpanId       = fixture.Create <string>();
            var testTraceId      = fixture.Create <string>();
            var testParentSpanId = fixture.Create <string>();
            var testName         = fixture.Create <string>();

            Span span = new Span();

            span.Id       = testSpanId;
            span.TraceId  = testTraceId;
            span.ParentId = testParentSpanId;
            span.Name     = testName;

            spanCollector.Collect(span);

            Assert.AreEqual(1, SpanCollector.spanQueue.Count);

            Span queuedSpan;
            var  spanInQueue = SpanCollector.spanQueue.TryTake(out queuedSpan);

            Assert.AreEqual(span, queuedSpan);
        }
コード例 #2
0
        public void Collect_NullSpan_NotCollect()
        {
            var collection = new BlockingCollection <Span>();
            var collector  = new SpanCollector(collection);

            collector.Collect(null);

            Assert.AreEqual(collection.Count, 0);
        }
コード例 #3
0
        public void Collect_NewSpan_AddedToCollection()
        {
            var collection = new BlockingCollection <Span>();
            var collector  = new SpanCollector(collection);

            var traceInfo = new TraceInfo(string.Empty, string.Empty, true, false, null, IPAddress.Loopback);

            collector.Collect(new Span(string.Empty, traceInfo));

            Assert.AreEqual(collection.Count, 1);
        }
コード例 #4
0
        public virtual void SendServerSpan(Span span)
        {
            if (span == null)
            {
                throw new ArgumentNullException(nameof(span));
            }

            if (span.Annotations == null || !span.Annotations.Any())
            {
                throw new ArgumentException("Invalid server span: Annotations list is invalid.");
            }

            var annotation = new Annotation()
            {
                Host  = span.Annotations.First().Host,
                Value = ZipkinConstants.ServerSend
            };

            span.Annotations.Add(annotation);

            spanCollector.Collect(span);
        }