Esempio n. 1
0
 private static void ConfigureSampler(OpenTelemetryOptions openTelemetryOptions, TracerProviderBuilder configure)
 {
     if (openTelemetryOptions.AlwaysOnSampler)
     {
         configure.SetSampler(new AlwaysOnSampler());
     }
 }
Esempio n. 2
0
 private static void ConfigureOpenTelemetry(IServiceCollection services, OpenTelemetryOptions openTelemetryOptions)
 {
     services.AddOpenTelemetryTracing(configure =>
     {
         ConfigureSampler(openTelemetryOptions, configure);
         ConfigureInstrumentation(openTelemetryOptions, configure);
         ConfigureExporters(openTelemetryOptions, configure);
     });
 }
Esempio n. 3
0
        private static void ConfigureInstrumentation(OpenTelemetryOptions openTelemetryOptions, TracerProviderBuilder configure)
        {
            Sdk.SetDefaultTextMapPropagator(GetPropagator(openTelemetryOptions));

            configure.AddAspNetCoreInstrumentation();

            configure.AddHttpClientInstrumentation();

            configure.AddSqlClientInstrumentation();
        }
Esempio n. 4
0
        private static void ConfigureExporters(OpenTelemetryOptions openTelemetryOptions, TracerProviderBuilder configure)
        {
            if (openTelemetryOptions.Jaeger.Enabled)
            {
                configure.SetResourceBuilder(ResourceBuilder.CreateDefault()
                                             .AddService(openTelemetryOptions.Jaeger.ServiceName));

                configure.AddJaegerExporter(config =>
                {
                    config.AgentHost = openTelemetryOptions.Jaeger.Host;
                    config.AgentPort = openTelemetryOptions.Jaeger.Port;
                });
            }
        }
Esempio n. 5
0
        private static TextMapPropagator GetPropagator(OpenTelemetryOptions openTelemetryOptions)
        {
            var propagators = new List <TextMapPropagator>()
            {
                new TraceContextPropagator(),
                new BaggagePropagator(),
            };

            if (openTelemetryOptions.Istio)
            {
                propagators.Add(new B3Propagator());
            }

            return(new CompositeTextMapPropagator(propagators));
        }