public void StartClientSpan_MultipleDomainList()
        {
            var zipkinConfig = CreateZipkinConfigWithDefaultValues();

            zipkinConfig.NotToBeDisplayedDomainList = new List <string> {
                ".abc.net", ".xyz.net"
            };
            var tracerClient = SetupZipkinClient(zipkinConfig);
            var zipkinClient = (ZipkinClient)tracerClient;

            spanTracerStub          = GetSpanTracerStub();
            zipkinClient.spanTracer = spanTracerStub;
            var clientServiceName = "abc-sandbox";
            var uriAbsolutePath   = "/object";
            var methodName        = "GET";
            var spanName          = methodName;

            var expectedSpan = new Span();

            spanTracerStub.Expect(
                x => x.SendClientSpan(
                    Arg <string> .Is.Equal(spanName.ToLower()),
                    Arg <string> .Is.Equal(traceProvider.TraceId),
                    Arg <string> .Is.Equal(traceProvider.ParentSpanId),
                    Arg <string> .Is.Equal(traceProvider.SpanId),
                    Arg <Uri> .Is.Anything)).Return(expectedSpan);

            var result = tracerClient.StartClientTrace(new Uri("https://" + clientServiceName + ".xyz.net:8000" + uriAbsolutePath), methodName, traceProvider);

            Assert.AreEqual(expectedSpan, result);
        }
        public void StartClientSpan_UsingIpAddress()
        {
            var tracerClient = SetupZipkinClient();
            var zipkinClient = (ZipkinClient)tracerClient;

            spanTracerStub          = GetSpanTracerStub();
            zipkinClient.spanTracer = spanTracerStub;
            var clientServiceName = "192.168.178.178";
            var uriAbsolutePath   = "/object";
            var methodName        = "GET";
            var spanName          = methodName;

            var expectedSpan = new Span();

            spanTracerStub.Expect(
                x => x.SendClientSpan(
                    Arg <string> .Is.Equal(spanName.ToLower()),
                    Arg <string> .Is.Equal(traceProvider.TraceId),
                    Arg <string> .Is.Equal(traceProvider.ParentSpanId),
                    Arg <string> .Is.Equal(traceProvider.SpanId),
                    Arg <Uri> .Is.Anything)).Return(expectedSpan);

            var result = tracerClient.StartClientTrace(new Uri("https://" + clientServiceName + ".xyz.net:8000" + uriAbsolutePath), methodName, traceProvider);

            Assert.AreEqual(expectedSpan, result);
        }
        public void StartServerSpan_Exception()
        {
            var tracerClient = SetupZipkinClient();
            var zipkinClient = (ZipkinClient)tracerClient;

            spanTracerStub          = GetSpanTracerStub();
            zipkinClient.spanTracer = spanTracerStub;
            var uriHost         = "https://[email protected]";
            var uriAbsolutePath = "/object";
            var methodName      = "GET";
            var spanName        = methodName;
            var requestUri      = new Uri(uriHost + uriAbsolutePath);

            spanTracerStub.Expect(
                x => x.ReceiveServerSpan(
                    Arg <string> .Is.Equal(spanName.ToLower()),
                    Arg <string> .Is.Anything,
                    Arg <string> .Is.Anything,
                    Arg <string> .Is.Anything,
                    Arg <Uri> .Is.Equal(requestUri))).Throw(new Exception());

            var result = tracerClient.StartServerTrace(requestUri, methodName);

            Assert.IsNull(result);
        }
        public void StartServerSpan()
        {
            var tracerClient = SetupZipkinClient();
            var zipkinClient = (ZipkinClient)tracerClient;

            spanTracerStub          = GetSpanTracerStub();
            zipkinClient.spanTracer = spanTracerStub;
            var uriHost         = "https://[email protected]";
            var uriAbsolutePath = "/object";
            var methodName      = "GET";
            var spanName        = methodName;
            var requestUri      = new Uri(uriHost + uriAbsolutePath);

            var expectedSpan = new Span();

            spanTracerStub.Expect(
                x => x.ReceiveServerSpan(
                    Arg <string> .Is.Equal(spanName.ToLower()),
                    Arg <string> .Is.Equal(traceProvider.TraceId),
                    Arg <string> .Is.Equal(traceProvider.ParentSpanId),
                    Arg <string> .Is.Equal(traceProvider.SpanId),
                    Arg <Uri> .Is.Equal(requestUri))).Return(expectedSpan);

            var result = tracerClient.StartServerTrace(requestUri, methodName);

            Assert.AreEqual(expectedSpan, result);
        }
        public void EndServerSpan_Exception()
        {
            var tracerClient = SetupZipkinClient();
            var zipkinClient = (ZipkinClient)tracerClient;

            spanTracerStub          = GetSpanTracerStub();
            zipkinClient.spanTracer = spanTracerStub;
            var serverSpan = new Span();

            spanTracerStub.Expect(x => x.SendServerSpan(serverSpan)).Throw(new Exception());

            tracerClient.EndServerTrace(serverSpan);
        }
        public void EndClientSpan_Exception()
        {
            var returnCode   = fixture.Create <short>();
            var tracerClient = SetupZipkinClient();
            var zipkinClient = (ZipkinClient)tracerClient;

            spanTracerStub          = GetSpanTracerStub();
            zipkinClient.spanTracer = spanTracerStub;
            var clientSpan = new Span();

            spanTracerStub.Expect(x => x.ReceiveClientSpan(clientSpan, returnCode)).Throw(new Exception());

            tracerClient.EndClientTrace(clientSpan, returnCode);
        }
        public void EndClientSpan_Exception()
        {
            var tracerClient = SetupZipkinClient();
            var zipkinClient = (ZipkinClient)tracerClient;

            spanTracerStub          = MockRepository.GenerateStub <SpanTracer>(spanCollectorStub, fixture.Create <string>(), MockRepository.GenerateStub <ServiceEndpoint>());
            zipkinClient.spanTracer = spanTracerStub;
            zipkinClient.clientSpan = new Span();

            var expectedDuration = fixture.Create <int>();

            spanTracerStub.Expect(x => x.ReceiveClientSpan(zipkinClient.clientSpan, expectedDuration)).Throw(new Exception());

            tracerClient.EndClientTrace(expectedDuration);
        }
        public void StartClientSpan_Exception()
        {
            var tracerClient = SetupZipkinClient();
            var zipkinClient = (ZipkinClient)tracerClient;

            spanTracerStub          = MockRepository.GenerateStub <SpanTracer>(spanCollectorStub, fixture.Create <string>(), MockRepository.GenerateStub <ServiceEndpoint>());
            zipkinClient.spanTracer = spanTracerStub;

            var expectedSpan = new Span();

            spanTracerStub.Expect(x => x.SendClientSpan(Arg <string> .Is.Equal(requestName), Arg <string> .Is.Anything, Arg <string> .Is.Anything, Arg <string> .Is.Anything)).Throw(new Exception());

            tracerClient.StartClientTrace();

            Assert.AreEqual(null, zipkinClient.clientSpan);
        }
        public void StartServerSpan()
        {
            var tracerClient = SetupZipkinClient();
            var zipkinClient = (ZipkinClient)tracerClient;

            spanTracerStub          = MockRepository.GenerateStub <SpanTracer>(spanCollectorStub, fixture.Create <string>(), MockRepository.GenerateStub <ServiceEndpoint>());
            zipkinClient.spanTracer = spanTracerStub;

            var expectedSpan = new Span();

            spanTracerStub.Expect(x => x.ReceiveServerSpan(Arg <string> .Is.Equal(requestName), Arg <string> .Is.Anything, Arg <string> .Is.Anything, Arg <string> .Is.Anything)).Return(expectedSpan);

            tracerClient.StartServerTrace();

            Assert.AreEqual(expectedSpan, zipkinClient.serverSpan);
        }
        public void StartClientSpan_Exception()
        {
            var tracerClient = SetupZipkinClient();
            var zipkinClient = (ZipkinClient)tracerClient;

            spanTracerStub          = GetSpanTracerStub();
            zipkinClient.spanTracer = spanTracerStub;
            var clientServiceName = "abc-sandbox";
            var uriAbsolutePath   = "/object";
            var methodName        = "GET";
            var spanName          = methodName;

            spanTracerStub.Expect(
                x => x.SendClientSpan(
                    Arg <string> .Is.Equal(spanName.ToLower()),
                    Arg <string> .Is.Anything,
                    Arg <string> .Is.Anything,
                    Arg <string> .Is.Anything,
                    Arg <Uri> .Is.Anything)).Throw(new Exception());

            var result = tracerClient.StartClientTrace(new Uri("https://" + clientServiceName + ".xyz.net:8000" + uriAbsolutePath), methodName, traceProvider);

            Assert.IsNull(result);
        }
        public void EndClientSpan_Exception()
        {
            var tracerClient = SetupZipkinClient();
            var zipkinClient = (ZipkinClient)tracerClient;
            spanTracerStub = MockRepository.GenerateStub<SpanTracer>(spanCollectorStub, fixture.Create<string>(), MockRepository.GenerateStub<ServiceEndpoint>());
            zipkinClient.spanTracer = spanTracerStub;
            zipkinClient.clientSpan = new Span();

            var expectedDuration = fixture.Create<int>();

            spanTracerStub.Expect(x => x.ReceiveClientSpan(zipkinClient.clientSpan, expectedDuration)).Throw(new Exception());

            tracerClient.EndClientTrace(expectedDuration);
        }
        public void StartClientSpan_Exception()
        {
            var tracerClient = SetupZipkinClient();
            var zipkinClient = (ZipkinClient)tracerClient;
            spanTracerStub = MockRepository.GenerateStub<SpanTracer>(spanCollectorStub, fixture.Create<string>(), MockRepository.GenerateStub<ServiceEndpoint>());
            zipkinClient.spanTracer = spanTracerStub;

            var expectedSpan = new Span();
            spanTracerStub.Expect(x => x.SendClientSpan(Arg<string>.Is.Equal(requestName), Arg<string>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything)).Throw(new Exception());

            tracerClient.StartClientTrace();

            Assert.AreEqual(null, zipkinClient.clientSpan);
        }
        public void StartServerSpan()
        {
            var tracerClient = SetupZipkinClient();
            var zipkinClient = (ZipkinClient)tracerClient;
            spanTracerStub = MockRepository.GenerateStub<SpanTracer>(spanCollectorStub, fixture.Create<string>(), MockRepository.GenerateStub<ServiceEndpoint>());
            zipkinClient.spanTracer = spanTracerStub;

            var expectedSpan = new Span();
            spanTracerStub.Expect(x => x.ReceiveServerSpan(Arg<string>.Is.Equal(requestName), Arg<string>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything)).Return(expectedSpan);

            tracerClient.StartServerTrace();

            Assert.AreEqual(expectedSpan, zipkinClient.serverSpan);
        }