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

Installation

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

Steps:
  1. 1.
    Initialize OpenTelemetry
  2. 2.
    Set the OpenTelemetry Resource, which must include your service.name
  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
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(YOUR_SERVICE_NAME))
.AddAspNetCoreInstrumentation()
// Add other instrumentation libraries here, for example AddHttpClientInstrumentation()
.AddOtlpExporter(otlpOptions =>
{
otlpOptions.Endpoint = new Uri("https://otelcol.aspecto.io:4317");
otlpOptions.Headers = "Authorization={YOUR_ASPECTO_TOKEN}";
}));
}

More Info

You can see more examples and documentation in the project's github repo​
Last modified 10mo ago
Copy link
On this page
Installation
Setup OpenTelemetry SDK in Code
More Info