-
Book Overview & Buying
-
Table Of Contents
Modern Distributed Tracing in .NET
By :
As we saw in the previous chapters, distributed tracing in .NET relies on primitives in the System.Diagnostics namespace: Activity and ActivitySource. They’re used by HTTP Client and ASP.NET Core instrumentations.
The terminology used by .NET and OpenTelemetry is different: Activity represents the OpenTelemetry span, ActivitySource maps to the tracer, and tags map to attributes.
The OpenTelemetry.Api NuGet package also provides TelemetrySpan, Tracer, and several more auxiliary classes in the OpenTelemetry.Trace namespace. These APIs are a shim over .NET tracing APIs – a thin wrapper that does not provide any additional functionality on top of .NET tracing APIs.
You are probably wondering which one you should use. The rule of thumb is to use .NET APIs unless you want to stick to OpenTelemetry terminology. Shim is just an additional layer, which brings a small performance overhead.