# Video

# Distributed Tracing

In the Kubernetes/OpenShift world, the de-facto standard for distributed tracing through microservices is OpenTracing (opens new window) and Jaeger (opens new window). Jaeger and OpenTracing are available as libraries for ASP.NET applications as well.

  1. Install the OpenTracing package
    cd <solution root>/src/RedHat.TodoList
    dotnet add package OpenTracing.Contrib.NetCore
    dotnet add package Jaeger.Core
    
  2. Enable OpenTracing in your Startup.cs file as follows:
       public void ConfigureServices(IServiceCollection services)
       {
    
          // Add framework services.
          services.AddOpenTracing();
          // Adds the Jaeger Tracer.
          services.AddSingleton<ITracer>(serviceProvider =>
          {
             string serviceName = serviceProvider.GetRequiredService<IWebHostEnvironment>().ApplicationName;
    
             // This will log to a default localhost installation of Jaeger.
             var tracer = new Tracer.Builder(serviceName)
                .WithSampler(new ConstSampler(true))
                .Build();
    
             // Allows code that can't use DI to also access the tracer.
             GlobalTracer.Register(tracer);
    
             return tracer;
          });
    
  3. Now, you can use Environment Variables or settings in appsettings.json to configure (opens new window) where to send the tracing data
Last Updated: 12/18/2021, 5:53:27 PM