Add OpenTelemetry to your .NET application and export the traces to Aspecto's collector


dotnet add package OpenTelemetry.Extensions.Hosting --prerelease
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol
Then, install instrumentations libraries that are relevant to your applications, for example:
dotnet add package OpenTelemetry.Instrumentation.AspNetCore --prerelease
You can browse all available instrumentation libraries in opentelemetry-dotnet repo and opentelemetry-dotnet-contrib repo

Setup OpenTelemetry SDK in Code

  1. 1.
    Initialize OpenTelemetry
  2. 2.
    Set the OpenTelemetry Resource, which must include your
  3. 3.
    Add Instrumentation Libraries which you installed
  4. 4.
    Configure OTLP exporter to send traces to Aspecto. You can find your Aspecto Token here​
For ASP.NET Core, you need to add this code to the ConfigureServices function in Startup.cs:
public void ConfigureServices(IServiceCollection services)
// your existing code here
services.AddOpenTelemetryTracing((builder) => builder
// Add other instrumentation libraries here, for example AddHttpClientInstrumentation()
.AddOtlpExporter(otlpOptions =>
otlpOptions.Endpoint = new Uri("");
otlpOptions.Headers = "Authorization={YOUR_ASPECTO_TOKEN}";

More Info

You can see more examples and documentation in the project's github repo​
Last modified 5mo ago