public SpanTracer(SpanCollector spanCollector, ServiceEndpoint zipkinEndpoint, IEnumerable <string> zipkinNotToBeDisplayedDomainList, Uri domain) { if (spanCollector == null) { throw new ArgumentNullException(nameof(spanCollector)); } if (zipkinEndpoint == null) { throw new ArgumentNullException(nameof(zipkinEndpoint)); } if (zipkinNotToBeDisplayedDomainList == null) { throw new ArgumentNullException(nameof(zipkinNotToBeDisplayedDomainList)); } if (domain == null) { throw new ArgumentNullException(nameof(domain)); } this.spanCollector = spanCollector; this.zipkinEndpoint = zipkinEndpoint; this.zipkinNotToBeDisplayedDomainList = zipkinNotToBeDisplayedDomainList; var domainHost = domain.Host; this.serviceName = CleanServiceName(domainHost); this.servicePort = (ushort)domain.Port; }
static SpanCollector GetInstance(Uri uri, uint maxProcessorBatchSize) { SyncHelper.ExecuteSafely(syncObj, () => instance == null, () => { instance = new SpanCollector(uri, maxProcessorBatchSize); }); return(instance); }
public ZipkinClient(IZipkinConfig zipkinConfig, IOwinContext 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; this.logger = LogProvider.GetCurrentClassLogger(); 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) { logger.Log(LogLevel.Error, () => "Error Building Zipkin Client Provider", ex); IsTraceOn = false; } }