public ZipkinClient(ILog logger, IZipkinConfig zipkinConfig, IOwinContext context, SpanCollector collector = null) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } 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; this.logger = logger; try { spanCollector = collector ?? SpanCollector.GetInstance( zipkinConfig.ZipkinBaseUri, zipkinConfig.SpanProcessorBatchSize, logger); spanTracer = new SpanTracer( spanCollector, new ServiceEndpoint(), zipkinConfig.NotToBeDisplayedDomainList, zipkinConfig.Domain); TraceProvider = traceProvider; } catch (Exception ex) { logger.Error("Error Building Zipkin Client Provider", ex); IsTraceOn = false; } }
public override async Task Invoke(IOwinContext context) { if (_config.Bypass != null && _config.Bypass(context.Request)) { await Next.Invoke(context); return; } var zipkin = new ZipkinClient(_config, context); var span = zipkin.StartServerTrace(context.Request.Uri, context.Request.Method); await Next.Invoke(context); zipkin.EndServerTrace(span); }