public void SendClientSpanWithDomainUnderFilterList()
        {
            var domain       = new Uri("https://server.com");
            var requestName  = fixture.Create <string>();
            var traceId      = fixture.Create <long>().ToString();
            var parentSpanId = fixture.Create <long>().ToString();
            var spanId       = fixture.Create <long>().ToString();
            var serverUri    = new Uri("https://" + clientServiceName + zipkinNotToBeDisplayedDomainList.First() + ":" + port + api);

            var spanTracer = new SpanTracer(spanCollectorStub, zipkinEndpointStub, zipkinNotToBeDisplayedDomainList, domain);

            var localEndpoint = new Endpoint {
                ServiceName = serverServiceName
            };

            zipkinEndpointStub.Expect(x => x.GetLocalEndpoint(Arg.Is(domain.Host), Arg <ushort> .Is.Anything)).Return(localEndpoint);
            var remoteEndpoint = new Endpoint {
                ServiceName = clientServiceName
            };

            zipkinEndpointStub.Expect(x => x.GetRemoteEndpoint(Arg.Is(serverUri), Arg.Is(clientServiceName))).Return(remoteEndpoint);

            var resultSpan = spanTracer.SendClientSpan(requestName, traceId, parentSpanId, spanId, serverUri);

            var endpoint = resultSpan.GetAnnotationsByType <BinaryAnnotation>().ToArray()[1].Host as Endpoint;

            Assert.IsNotNull(endpoint);
            Assert.AreEqual(clientServiceName, endpoint.ServiceName);
        }
Пример #2
0
        public void SendClientSpan()
        {
            var domain       = new Uri("https://server.com");
            var requestName  = fixture.Create <string>();
            var traceId      = Guid.NewGuid().ToString("N");
            var parentSpanId = fixture.Create <long>().ToString("x");
            var spanId       = fixture.Create <long>().ToString("x");
            var serverUri    = new Uri("https://" + clientServiceName + ":" + port + api);

            var spanTracer = new SpanTracer(spanCollectorStub, zipkinEndpointStub, zipkinNotToBeDisplayedDomainList, domain);

            var localEndpoint = new Endpoint {
                ServiceName = serverServiceName
            };

            zipkinEndpointStub.Expect(x => x.GetLocalEndpoint(Arg.Is(domain.Host), Arg <ushort> .Is.Anything)).Return(localEndpoint);
            var remoteEndpoint = new Endpoint {
                ServiceName = clientServiceName, Port = port
            };

            zipkinEndpointStub.Expect(x => x.GetRemoteEndpoint(Arg.Is(serverUri), Arg.Is(clientServiceName))).Return(remoteEndpoint);

            var resultSpan = spanTracer.SendClientSpan(requestName, traceId, parentSpanId, spanId, serverUri);

            Assert.AreEqual(requestName, resultSpan.Name);
            Assert.AreEqual(traceId, resultSpan.TraceId);
            Assert.AreEqual(parentSpanId, resultSpan.ParentId);
            Assert.AreEqual(spanId, resultSpan.Id);



            Assert.AreEqual(1, resultSpan.GetAnnotationsByType <Annotation>().Count());

            var annotation = resultSpan.Annotations[0] as Annotation;

            Assert.IsNotNull(annotation);
            Assert.AreEqual(ZipkinConstants.ClientSend, annotation.Value);
            Assert.IsNotNull(annotation.Timestamp);
            Assert.AreEqual(localEndpoint, annotation.Host);

            var binaryAnnotations = resultSpan.GetAnnotationsByType <BinaryAnnotation>();

            Assert.AreEqual(2, binaryAnnotations.Count());
            AssertBinaryAnnotations(binaryAnnotations, "http.path", serverUri.AbsolutePath);
            AssertBinaryAnnotations(binaryAnnotations, "sa", "1");

            var endpoint = binaryAnnotations.ToArray()[1].Host as Endpoint;

            Assert.IsNotNull(endpoint);
            Assert.AreEqual(clientServiceName, endpoint.ServiceName);
            Assert.AreEqual(port, endpoint.Port);
        }
Пример #3
0
        public Span StartClientTrace(Uri remoteUri, string methodName, ITraceProvider trace)
        {
            if (!IsTraceOn)
            {
                return(null);
            }

            try
            {
                return(spanTracer.SendClientSpan(
                           methodName.ToLower(),
                           trace.TraceId,
                           trace.ParentSpanId,
                           trace.SpanId,
                           remoteUri));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Пример #4
0
        public void SendClientSpan()
        {
            var serviceName  = fixture.Create <string>();
            var requestName  = fixture.Create <string>();
            var traceId      = fixture.Create <long>().ToString();
            var parentSpanId = fixture.Create <long>().ToString();
            var spanId       = fixture.Create <long>().ToString();

            var spanTracer = new SpanTracer(spanCollectorStub, serviceName, zipkinEndpointStub);

            zipkinEndpointStub.Expect(x => x.GetEndpoint(serviceName)).Return(new Endpoint()
            {
                Service_name = serviceName
            });

            var resultSpan = spanTracer.SendClientSpan(requestName, traceId, parentSpanId, spanId);

            Assert.AreEqual(requestName, resultSpan.Name);
            Assert.AreEqual(Int64.Parse(traceId, System.Globalization.NumberStyles.HexNumber), resultSpan.Trace_id);
            Assert.AreEqual(Int64.Parse(parentSpanId, System.Globalization.NumberStyles.HexNumber), resultSpan.Parent_id);
            Assert.AreEqual(Int64.Parse(spanId, System.Globalization.NumberStyles.HexNumber), resultSpan.Id);

            Assert.AreEqual(1, resultSpan.Annotations.Count);

            var annotation = resultSpan.Annotations[0] as Annotation;

            Assert.IsNotNull(annotation);
            Assert.AreEqual(zipkinCoreConstants.CLIENT_SEND, annotation.Value);
            Assert.IsNotNull(annotation.Timestamp);
            Assert.IsNotNull(annotation.Host);

            var endpoint = annotation.Host as Endpoint;

            Assert.IsNotNull(endpoint);
            Assert.AreEqual(serviceName, endpoint.Service_name);

            AssertBinaryAnnotations(resultSpan.Binary_annotations, traceId, spanId, parentSpanId);
        }
        public void SendClientSpan()
        {
            var serviceName = fixture.Create<string>();
            var requestName = fixture.Create<string>();
            var traceId = fixture.Create<long>().ToString();
            var parentSpanId = fixture.Create<long>().ToString();
            var spanId = fixture.Create<long>().ToString();

            var spanTracer = new SpanTracer(spanCollectorStub, serviceName, zipkinEndpointStub);

            zipkinEndpointStub.Expect(x => x.GetEndpoint(serviceName)).Return(new Endpoint() { Service_name = serviceName });

            var resultSpan = spanTracer.SendClientSpan(requestName, traceId, parentSpanId, spanId);
            Assert.AreEqual(requestName, resultSpan.Name);
            Assert.AreEqual(Int64.Parse(traceId, System.Globalization.NumberStyles.HexNumber), resultSpan.Trace_id);
            Assert.AreEqual(Int64.Parse(parentSpanId, System.Globalization.NumberStyles.HexNumber), resultSpan.Parent_id);
            Assert.AreEqual(Int64.Parse(spanId, System.Globalization.NumberStyles.HexNumber), resultSpan.Id);

            Assert.AreEqual(1, resultSpan.Annotations.Count);

            var annotation = resultSpan.Annotations[0] as Annotation;
            Assert.IsNotNull(annotation);
            Assert.AreEqual(zipkinCoreConstants.CLIENT_SEND, annotation.Value);
            Assert.IsNotNull(annotation.Timestamp);
            Assert.IsNotNull(annotation.Host);

            var endpoint = annotation.Host as Endpoint;
            Assert.IsNotNull(endpoint);
            Assert.AreEqual(serviceName, endpoint.Service_name);

            AssertBinaryAnnotations(resultSpan.Binary_annotations, traceId, spanId, parentSpanId);
        }