public void Apply(Tracer.Builder builder) { // Replace existing TEXT_MAP and HTTP_HEADERS codec with one that represents the // configured propagation formats RegisterCodec(builder, BuiltinFormats.HttpHeaders); RegisterCodec(builder, BuiltinFormats.TextMap); }
public Tracer.Builder GetTracerBuilder() { if (ReporterConfig == null) { ReporterConfig = new ReporterConfiguration(_loggerFactory); } if (SamplerConfig == null) { SamplerConfig = new SamplerConfiguration(_loggerFactory); } if (_codecConfig == null) { _codecConfig = new CodecConfiguration(new Dictionary <IFormat <ITextMap>, List <Codec <ITextMap> > >()); } if (_metricsFactory == null) { _metricsFactory = NoopMetricsFactory.Instance; } IMetrics metrics = new MetricsImpl(_metricsFactory); IReporter reporter = ReporterConfig.GetReporter(metrics); ISampler sampler = SamplerConfig.CreateSampler(_serviceName, metrics); Tracer.Builder builder = new Tracer.Builder(_serviceName) .WithLoggerFactory(_loggerFactory) .WithSampler(sampler) .WithReporter(reporter) .WithMetrics(metrics) .WithTags(_tracerTags); _codecConfig.Apply(builder); return(builder); }
protected void RegisterCodec(Tracer.Builder builder, IFormat <ITextMap> format) { if (_codecs.ContainsKey(format)) { List <Codec <ITextMap> > codecsForFormat = _codecs[format]; Codec <ITextMap> codec = codecsForFormat.Count == 1 ? codecsForFormat[0] : new CompositeCodec <ITextMap>(codecsForFormat); builder.RegisterCodec(format, codec); } }
public Tracer.Builder GetTracerBuilder() { if (ReporterConfig == null) { ReporterConfig = new ReporterConfiguration(_loggerFactory); } if (SamplerConfig == null) { SamplerConfig = new SamplerConfiguration(_loggerFactory); } if (CodecConfig == null) { CodecConfig = new CodecConfiguration(_loggerFactory); } if (_metricsFactory == null) { _metricsFactory = NoopMetricsFactory.Instance; } IMetrics metrics = new MetricsImpl(_metricsFactory); IReporter reporter = ReporterConfig.GetReporter(metrics); ISampler sampler = SamplerConfig.GetSampler(ServiceName, metrics); Tracer.Builder builder = new Tracer.Builder(ServiceName) .WithLoggerFactory(_loggerFactory) .WithSampler(sampler) .WithReporter(reporter) .WithMetrics(metrics) .WithTags(_tracerTags); if (UseTraceId128Bit) { builder = builder.WithTraceId128Bit(); } CodecConfig.Apply(builder); return(builder); }
public static IServiceCollection AddJaegerTracing(this IServiceCollection services, Action <JaegerOptions> setupAction = null) { if (setupAction != null) { services.ConfigureJaegerTracing(setupAction); } services.AddSingleton <ITracer>(cli => { ILoggerFactory loggerFactory = cli.GetRequiredService <ILoggerFactory>(); ILogger logger = loggerFactory.CreateLogger("Jaeger"); JaegerOptions options = cli.GetService <IOptions <JaegerOptions> >().Value; Configuration.SenderConfiguration.DefaultSenderResolver = new SenderResolver(loggerFactory) .RegisterSenderFactory <ThriftSenderFactory>(); var senderConfig = new Jaeger.Configuration.SenderConfiguration(loggerFactory) .WithAgentHost(options.Host) .WithAgentPort(options.Port); var reporter = new RemoteReporter.Builder() .WithLoggerFactory(loggerFactory) .WithSender(senderConfig.GetSender()) .Build(); logger.LogInformation($"Jaeger sending to {senderConfig.GetSender()}"); var sampler = new GuaranteedThroughputSampler(options.SamplingRate, options.LowerBound); var tracer = new Tracer.Builder(options.ServiceName ?? "Not Set") .WithLoggerFactory(loggerFactory) .WithReporter(reporter) .WithSampler(sampler) .Build(); // Allows code that can't use dependency injection to have access to the tracer. if (!GlobalTracer.IsRegistered()) { GlobalTracer.Register(tracer); } return(tracer); }); services.AddOpenTracing(builder => { builder.ConfigureAspNetCore(options => { options.Hosting.IgnorePatterns.Add(x => { return(x.Request.Path.Value.EndsWith("live", StringComparison.InvariantCultureIgnoreCase)); }); options.Hosting.IgnorePatterns.Add(x => { return(x.Request.Path.ToString().EndsWith("ready", StringComparison.InvariantCultureIgnoreCase)); }); options.Hosting.IgnorePatterns.Add(x => { return(x.Request.Path == "/metrics"); }); }); }); return(services); }