Components Overview - open-telemetry/opentelemetry-dotnet

This overview covers the main components of OpenTelemetry .NET, including the API, instrumentation libraries, and exporter libraries.

API

The OpenTelemetry API is a set of data types and operations for generating and correlating tracing, metrics, and logging data. It defines the requirements for a language-specific implementation of the API. The OpenTelemetry .NET API is a language-specific implementation of the OpenTelemetry API for the .NET programming language.

Source: https://opentelemetry.io/docs/instrumentation/net/

Instrumentation Libraries

Instrumentation libraries are code packages that automatically instrument your application to capture telemetry data. OpenTelemetry .NET provides instrumentation libraries for various technologies, such as ASP.NET Core, gRPC, and SQL Client.

Here are some examples of OpenTelemetry .NET instrumentation libraries:

  • OpenTelemetry.Instrumentation.AspNetCore for ASP.NET Core
  • OpenTelemetry.Instrumentation.Grpc for gRPC
  • OpenTelemetry.Instrumentation.SqlClient for Microsoft.Data.SqlClient and System.Data.SqlClient

Source: https://grafana.com/docs/opentelemetry/instrumentation/dotnet/

Manual Instrumentation

In addition to automatic instrumentation, OpenTelemetry .NET also supports manual instrumentation. Manual instrumentation allows you to add telemetry data collection to your application code manually.

Here is an example of manual instrumentation using the OpenTelemetry Tracing API:

using OpenTelemetry.Api.Trace;
using OpenTelemetry.Context.Propagation;

// Create a new activity source.
var activitySource = new ActivitySource("MyCompany.MyApp");

// Start a new activity.
using (var activity = activitySource.StartActivity("MyOperation"))
{
// Add some custom attributes.
activity.SetTag("my.key", "my.value");

// Do some work.
DoSomeWork();

// Set the status of the activity.
activity.SetStatus(ActivityStatusCode.Ok);
}

Source: https://opentelemetry.io/docs/instrumentation/net/manual/

Exporter Libraries

Exporter libraries are code packages that export telemetry data to a backend for processing and analysis. OpenTelemetry .NET provides exporter libraries for various backends, such as OpenTelemetry Collector, Jaeger, Zipkin, and Prometheus.

Here are some examples of OpenTelemetry .NET exporter libraries:

  • OpenTelemetry.Exporter.OTLP.Grpc for OpenTelemetry Collector
  • OpenTelemetry.Exporter.Jaeger for Jaeger
  • OpenTelemetry.Exporter.Zipkin for Zipkin
  • OpenTelemetry.Exporter.Prometheus for Prometheus

Source: https://opentelemetry.io/docs/instrumentation/net/exporters/

OpenTelemetry Collector

The OpenTelemetry Collector is a vendor-neutral daemon that receives, processes, and exports telemetry data from your application. It supports various input and output formats, such as OpenTelemetry Protocol (OTLP), Jaeger, Zipkin, and Prometheus.

Here are some use cases for the OpenTelemetry Collector:

  • Fan out: Send telemetry data to multiple backends.
  • Telemetry data normalization: Convert telemetry data from one format to another.
  • Kubernetes sidecars and daemon sets: Collect telemetry data from Kubernetes pods.
  • Load balancing: Distribute telemetry data to multiple backends.
  • Multi-cluster: Collect telemetry data from multiple clusters.
  • Multitenant: Collect telemetry data from multiple tenants.
  • Per signal: Send logs to Grafana Loki, metrics to Prometheus, and traces to Tempo.

Source: https://grafana.com/docs/opentelemetry/collector/how-to-scale/

Conclusion

OpenTelemetry .NET provides a set of components for generating, collecting, and exporting telemetry data from your .NET application. By using the OpenTelemetry API, instrumentation libraries, and exporter libraries, you can easily add observability to your application and gain insights into its performance and behavior. The OpenTelemetry Collector provides a vendor-neutral daemon for processing and exporting telemetry data to various backends.