OpenTelemetry .NET distro for Uptrace

This document explains how to configure OpenTelemetry .NET SDK to export spans and metrics to Uptrace using OTLP/gRPC.

To learn about OpenTelemetry API, see OpenTelemetry .NET Tracing APIopen in new window and OpenTelemetry .NET Metrics APIopen in new window.

OpenTelemetry .NET

To install uptrace-dotnet:

dotnet add package Uptrace.OpenTelemetry --prerelease


You can configure Uptrace client using a DSN (Data Source Name, e.g. https://<token><project_id>) from the project settings page.

using System;
using System.Diagnostics;

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

using Uptrace.OpenTelemetry;

var serviceName = "myservice";
var serviceVersion = "1.0.0";

var openTelemetry = Sdk.CreateTracerProviderBuilder()
    .AddSource("*") // subscribe to all activity sources
            .AddService(serviceName: serviceName, serviceVersion: serviceVersion)
    // copy your project DSN here or use UPTRACE_DSN env var

You can also use environment variables to configure the client:

Env varDescription
UPTRACE_DSNA data source that is used to connect to For example, https://<token><project_id>.
OTEL_RESOURCE_ATTRIBUTESKey-value pairs to be used as resource attributes. For example,,service.version=1.0.0.
OTEL_PROPAGATORSPropagators to be used as a comma separated list. The default is tracecontext,baggage.

Getting started

Install OpenTelemetry distro, generate your first trace, and click the link in your terminal to open Uptrace. All it takes is a minute of your time.

git clone
cd example/basic
  • Step 2. Run the example to get a link for the generated trace:
$ UPTRACE_DSN="https://<token><project_id>" dotnet run<trace_id>
  • Step 3. Follow the link to view the trace:

Basic trace

What's next?

Last Updated: