Exemplo n.º 1
0
 public ZipkinMiddleware(
     OwinMiddleware next,
     string serviceName,
     ITraceExtractor traceExtractor) : base(next)
 {
     this.serviceName    = serviceName;
     this.traceExtractor = traceExtractor;
 }
Exemplo n.º 2
0
        public OtTracer(string serviceName, IScopeManager scopeManager, ITraceInjector traceInjector, ITraceExtractor traceExtractor)
        {
            ServiceName  = serviceName ?? throw new ArgumentNullException(nameof(serviceName));
            ScopeManager = scopeManager ?? throw new ArgumentNullException(nameof(scopeManager));

            _traceInjector  = traceInjector ?? throw new ArgumentNullException(nameof(traceInjector));
            _traceExtractor = traceExtractor ?? throw new ArgumentNullException(nameof(traceExtractor));
        }
Exemplo n.º 3
0
        public void Setup()
        {
            logger         = Substitute.For <ILogger>();
            tracer         = new InMemoryTracer();
            traceExtractor = Substitute.For <ITraceExtractor>();


            TraceManager.SamplingRate = 1.0f;
            TraceManager.RegisterTracer(tracer);
            TraceManager.Start(logger);
        }
Exemplo n.º 4
0
        internal static Action <IAppBuilder> DefaultStartup(string serviceName, ITraceExtractor traceExtractor)
        {
            return
                (app =>
            {
                app.UseZipkinTracer(serviceName, traceExtractor);

                app.Run(async context =>
                {
                    context.Response.ContentType = "text/plain";
                    await context.Response.WriteAsync(DateTime.Now.ToString());
                });
            });
        }
Exemplo n.º 5
0
        /// <summary>
        /// 通过跟踪配置初始化一个跟踪
        /// </summary>
        /// <param name="option"></param>
        public TraceProvider(TraceOptions option)
        {
            //创建默认log器
            var log = new LogFactory();

            var logger = new TraceLogger(new Log <TraceLogger>(log));
            //创建发送实例
            var sender = new HttpZipkinSender(option.Endpoint, "application/json");

            logger.LogInformation($"{nameof(option.Endpoint)}:{option.Endpoint}");

            TraceManager.SamplingRate = option.SamplingRate;

            logger.LogInformation($"{nameof(option.SamplingRate)}:{option.SamplingRate}");
            //创建跟踪
            var tracer = new ZipkinTracer(new RateLimiterZipkinSender(sender, option.MaxRequest, option.Duration), new JSONSpanSerializer());

            //注册跟踪
            TraceManager.RegisterTracer(tracer);
            //开始
            TraceManager.Start(logger);

            _extractor = new ZipkinHttpTraceExtractor();
        }
Exemplo n.º 6
0
 public static IAppBuilder UseZipkinTracer(this IAppBuilder appBuilder, string serviceName, ITraceExtractor traceExtractor)
 => appBuilder.Use <ZipkinMiddleware>(serviceName, traceExtractor);