Exporters
In order to visualize and analyze your traces and metrics, you will need to export them to a backend.
Console exporter¶
The console exporter is useful for development and debugging tasks, and is the simplest to set up.
If you're using ASP.NET Core, configure the exporter in your ASP.NET Core services:
Otherwise, configure the exporter when creating a tracer provider:
OTLP endpoint¶
To send trace data to an OTLP endpoint (like the collector or Jaeger) you'll want to configure an OTLP exporter that sends to your endpoint.
If you're using ASP.NET Core, configure the exporter in your ASP.NET Core services:
This will, by default, send traces using gRPC to http://localhost:4317, to customize this to use HTTP and the protobuf format, you can add options like this:
Otherwise, configure the exporter when creating a tracer provider:
Use environment variables to set values like headers and an endpoint URL for production.
Note for .NET Core 3.1 and below and gRPC¶
Note: Versions below .NET 6 are not officially supported by opentelemetry-dotnet, therefore this section is here to help, but may not work as the library progresses.
If you're not using ASP.NET Core gRPC and you are running on .NET Core 3.x, you'll need to add the following at application startup
If you are using .NET 5 or higher, the previous code sample is not required.
Jaeger¶
To try out the OTLP exporter, you can run Jaeger as an OTLP endpoint and for trace visualization in a docker container:
Zipkin¶
If you are using Zipkin to visualize trace data, you'll need to set it up first. This is how to run it in a docker container:
Next, install the Zipkin exporter package:
If you're using ASP.NET Core, configure the exporter in your ASP.NET Core services:
Otherwise, configure the exporter when creating a tracer provider:
Prometheus (Experimental)¶
*Note: this is experimental and dependent on the OpenTelemetry specification to be made stable before it will be a released package. For now, we recommend using the OTLP exporter and using the OpenTelemetry Collector to send metrics to Prometheus*
If you're using Prometheus to visualize metrics data, you'll need to set it up first. Here's how to do it using a docker container:
First, you'll need a prometheus.yml
file to configure your Prometheus backend,
such as the following:
Next, run the following docker command to set up Prometheus:
Next, install the Prometheus exporter:
ASP.NET¶
If you're using ASP.NET Core, configure the exporter in your ASP.NET Core services:
You'll then need to add the endpoint so that Prometheus can scrape your site.
You can do this using the IAppBuilder
extension like this:
Non-ASP.NET Core¶
For applications not using ASP.NET Core, you can use the HttpListener
version
which is available in a different package:
Then this is setup directly on the MeterProviderBuilder
:
Finally, register the Prometheus scraping middleware using the
UseOpenTelemetryPrometheusScrapingEndpoint
extension method on
IApplicationBuilder
:
Further details on configuring the Prometheus exporter can be found here.
Next steps¶
To ensure you're getting the most data as easily as possible, install instrumentation libraries to generate observability data.
Additionally, enriching your codebase with manual instrumentation gives you customized observability data.
You can also check the automatic instrumentation for .NET, which is currently in beta.