Example #1
0
        public void StartProcessingSpans()
        {
            SetupSpanCollector();

            spanCollector.Start();

            spanProcessorStub.AssertWasCalled(x => x.Start());
            Assert.IsTrue(spanCollector.IsStarted);
        }
Example #2
0
        public ZipkinClient(IZipkinConfig zipkinConfig, HttpContext context, SpanCollector collector = null)
        {
            if (zipkinConfig == null)
            {
                throw new ArgumentNullException(nameof(zipkinConfig));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            var traceProvider = new TraceProvider(zipkinConfig, context);

            IsTraceOn = !zipkinConfig.Bypass(context.Request) && IsTraceProviderSamplingOn(traceProvider);

            if (!IsTraceOn)
            {
                return;
            }

            zipkinConfig.Validate();
            ZipkinConfig = zipkinConfig;
            try
            {
                spanCollector = collector ?? GetInstance(
                    zipkinConfig.ZipkinBaseUri,
                    zipkinConfig.SpanProcessorBatchSize);

                spanCollector.Start();

                spanTracer = new SpanTracer(
                    spanCollector,
                    new ServiceEndpoint(),
                    zipkinConfig.NotToBeDisplayedDomainList,
                    zipkinConfig.Domain(context.Request));

                TraceProvider = traceProvider;
            }
            catch (Exception ex)
            {
                IsTraceOn = false;
            }
        }