Esempio n. 1
0
        private static ISampler GetSampler(JaegerOptions options)
        {
            switch (options.Sampler)
            {
            case "const": return(new ConstSampler(true));

            case "rate": return(new RateLimitingSampler(options.MaxTracesPerSecond));

            case "probabilistic": return(new ProbabilisticSampler(options.SamplingRate));

            default: return(new ConstSampler(true));
            }
        }
Esempio n. 2
0
        public static IFixerBuilder AddJaeger(this IFixerBuilder builder, JaegerOptions options)
        {
            builder.Services.AddSingleton(options);
            if (!options.Enabled)
            {
                var defaultTracer = ConveyDefaultTracer.Create();
                builder.Services.AddSingleton(defaultTracer);
                return(builder);
            }

            if (!builder.TryRegister(RegistryName) || _initialized)
            {
                return(builder);
            }

            _initialized = true;
            builder.Services.AddSingleton <ITracer>(sp =>
            {
                var loggerFactory = sp.GetRequiredService <ILoggerFactory>();

                var reporter = new RemoteReporter.Builder()
                               .WithSender(new UdpSender(options.UdpHost, options.UdpPort, options.MaxPacketSize))
                               .WithLoggerFactory(loggerFactory)
                               .Build();

                var sampler = GetSampler(options);

                var tracer = new Tracer.Builder(options.ServiceName)
                             .WithLoggerFactory(loggerFactory)
                             .WithReporter(reporter)
                             .WithSampler(sampler)
                             .Build();

                GlobalTracer.Register(tracer);

                return(tracer);
            });

            return(builder);
        }