Exporter Libraries - open-telemetry/opentelemetry-dotnet

Exporter Libraries in OpenTelemetry .NET

OpenTelemetry is an observability framework that helps generate and collect application telemetry data such as metrics, logs, and traces. The .NET implementation of OpenTelemetry provides several exporter libraries to export telemetry data to different backends.

Exporter Libraries in OpenTelemetry .NET include:

  1. OTLP Exporter The OTLP (OpenTelemetry Protocol) exporter library allows exporting telemetry data in the OpenTelemetry Protocol (OTLP) format to the OpenTelemetry Collector and OTLP-compliant backends/receivers. To install the OTLP exporter, use the following command:
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol --version 1.5.1

To use the OTLP exporter, add a call to AddOtlpExporter after each call to AddConsoleExporter, resulting in the following Program.cs:

using OpenTelemetry.Metrics;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;

//...

using var tracerProvider = Sdk.CreateTracerProvider(
builder =>
{
//...
builder
.AddConsoleExporter()
.AddOtlpExporter(otlpExporterOptions =>
{
//...
});
});
  1. Prometheus Exporter The Prometheus exporter library allows exporting telemetry data in the Prometheus format. There are two types of Prometheus exporters available for .NET:
  • ASP.NET Core for OpenTelemetry: An OpenTelemetry Prometheus exporter for configuring an ASP.NET Core application with an endpoint for Prometheus to scrape.
  • HttpListener for OpenTelemetry: An OpenTelemetry Prometheus exporter that configures an HttpListener instance for Prometheus to scrape.

To install the Prometheus exporter, use the following command:

dotnet add package OpenTelemetry.Exporter.Prometheus --version 1.5.1

To use the Prometheus exporter, add a call to AddPrometheusHttpListenerExporter after each call to AddConsoleExporter, resulting in the following Program.cs:

using OpenTelemetry.Metrics;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;

//...

using var tracerProvider = Sdk.CreateTracerProvider(
builder =>
{
//...
builder
.AddConsoleExporter()
.AddPrometheusHttpListenerExporter();
});
  1. Console Exporter The console exporter library prints data to the Console window. To install the console exporter, use the following command:
dotnet add package OpenTelemetry.Exporter.Console --version 1.5.1

To use the console exporter, add a call to AddConsoleExporter after each call to AddTracing, resulting in the following Program.cs:

using OpenTelemetry.Resources;
using OpenTelemetry.Trace;

//...

using var tracerProvider = Sdk.CreateTracerProvider(
builder =>
{
//...
builder.AddConsoleExporter();
});
  1. Other Exporter Libraries Other exporter libraries available for OpenTelemetry .NET include Geneva, InfluxDB, In-memory, Instana, OneCollector, and Zipkin exporters.

For more information on exporter libraries in OpenTelemetry .NET, refer to the following resources: