.NET
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
Steps:
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}";
}));
}
Last modified 5mo ago