.NET Open Standards
Incident Management is now generally available! Incident Management is now generally available!

.NET Open Standards

OpenTracing

Datadog also supports the OpenTracing standard. For more details and information, view the OpenTracing API.

Setup

For OpenTracing support, add the Datadog.Trace.OpenTracing NuGet package to your application. During application start-up, initialize the OpenTracing library:

using Datadog.Trace.OpenTracing;

public void ConfigureServices(IServiceCollection services)
{
    // Create an OpenTracing ITracer with the default setting
    OpenTracing.ITracer tracer = OpenTracingTracerFactory.CreateTracer();

    // Use the tracer with ASP.NET Core dependency injection
    services.AddSingleton<ITracer>(tracer);

    // Use the tracer with OpenTracing.GlobalTracer.Instance
    GlobalTracer.Register(tracer);
}

Manually instrument a method

Use OpenTracing to create a span.

using (var scope =
       Tracer.Instance.StartActive("manual.sortorders"))
{
    SortOrders();
}

Asynchronous traces

To trace code running in an asynchronous task, create a new scope within the background task, just as you would wrap synchronous code.

 Task.Run(
     () =>
     {
         using (var scope =
                Tracer.Instance.StartActive("manual.sortorders.async"))
         {
             SortOrders();
         }
     });

Further Reading

Additional helpful documentation, links, and articles: