This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Comparing OpenTelemetry Trace API and .NET Activity API #947
Labels
documentation
Documentation related
pkg:OpenTelemetry.Api
Issues related to OpenTelemetry.Api NuGet package
Comparing the OpenTelemetry Trace API and .NET Activity API
Introduction
Starting with 5.0.0 version of DiagnosticSource, the recommendation from OpenTelemetry .NET is to use .NET Activity API as the OpenTelemetry Tracing API. .NET's Activity API existed for a long time, and has been recently improved (in 5.0.0) to enable all OpenTelemetry scenarios. The OpenTelemetry .NET API ships a shim on top of the Activity class, which may be used, as it offers familiar terminology like
Span
andTracer
. Irrespective of the API used, the final outcome is still the same - Processors and Exporters always getActivity
objects. In short,Activity
in .NET represents the OpenTelemetry Span..NET Activity API ships as part of the nuget System.Diagnostics.DiagnosticSource. Version 5.0.0 of the package is required, which was released along with .NET 5 release, but the package supports every versions of .NET which are officially supported. This includes .NET Framework 4.5.2 and above. .NET Core 2.XX, .NET Core 3.XX and, .NET 5.
Comparing the APIs
TracerProvider
As the name indicates, TracerProvider provides Tracer. The .NET equivalent of
Tracer
isActivitySource
. .NET has no equivalent concept ofTracerProvider
.ActivitySource
s are not obtained from aTracerProvider
, but are directly instantiated with name (and version optionally).Tracer
Tracer is responsible for creating Span. It also has a method to get the current active Span. In .NET,
ActivitySource
is the equivalent of the Tracer. Differences are noted below.Span
A Span represents a single operation within a trace. In .NET
Activity
class represents the span.The text was updated successfully, but these errors were encountered: