Example #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));
            }
        }
Example #2
0
        public static IConveyBuilder AddJaeger(this IConveyBuilder builder, JaegerOptions options)
        {
            if (Interlocked.Exchange(ref _initialized, 1) == 1)
            {
                return(builder);
            }

            builder.Services.AddSingleton(options);
            if (!options.Enabled)
            {
                var defaultTracer = ConveyDefaultTracer.Create();
                builder.Services.AddSingleton(defaultTracer);
                return(builder);
            }

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

            if (options.ExcludePaths is {})
Example #3
0
        public static IConveyBuilder AddJaeger(this IConveyBuilder 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);
        }