Send Metrics from ASP.NET Core using OpenTelemetry

SigNoz Cloud - This page applies to SigNoz Cloud editions.
Self-Host - This page applies to self-hosted SigNoz editions.

Instrument your ASP.NET Core application with OpenTelemetry NuGet packages and send HTTP, Kestrel, and .NET runtime metrics to SigNoz.

Prerequisites

Send Metrics to SigNoz

Step 1. Add NuGet packages

YourApp.csproj
<ItemGroup>
  <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.15.3" />
  <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.15.2" />
  <PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.15.1" />
  <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.15.3" />
</ItemGroup>

Or with the .NET CLI:

dotnet add package OpenTelemetry.Extensions.Hosting --version 1.15.3
dotnet add package OpenTelemetry.Instrumentation.AspNetCore --version 1.15.2
dotnet add package OpenTelemetry.Instrumentation.Runtime --version 1.15.1
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol --version 1.15.3

Step 2. Configure OpenTelemetry in Program.cs

Program.cs
using OpenTelemetry.Metrics;
using OpenTelemetry.Resources;

var builder = WebApplication.CreateBuilder(args);

var serviceName = Environment.GetEnvironmentVariable("OTEL_SERVICE_NAME") ?? "my-aspnetcore-app";

builder.Services.AddOpenTelemetry()
    .ConfigureResource(r => r.AddService(serviceName))
    .WithMetrics(m => m
        .AddAspNetCoreInstrumentation()
        .AddRuntimeInstrumentation()
        .AddMeter("Microsoft.AspNetCore.MemoryPool")
        .AddOtlpExporter());

var app = builder.Build();
// ... your routes ...
app.Run();

The OTel SDK reads OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, and OTEL_EXPORTER_OTLP_PROTOCOL automatically.

.AddMeter("Microsoft.AspNetCore.MemoryPool") enables aspnetcore.memory_pool.* metrics, which only emit on .NET 10+. On .NET 8 or 9, all other HTTP, Kestrel, and runtime metrics populate as expected. The memory pool panels stay empty.

Step 3. Set environment variables

export OTEL_SERVICE_NAME="my-aspnetcore-app"
export OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.<region>.signoz.cloud:443"
export OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your-ingestion-key>"
export OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
export OTEL_RESOURCE_ATTRIBUTES="deployment.environment=production"

Verify these values:

Step 4. Validate

Start your application, send some requests, then open SigNoz.

  1. Go to Metrics > Metrics Explorer.
  2. Search for http.server.request.duration.

Metrics appear within the first export interval (default: 60 seconds).

ASP.NET Core Sample Metrics
ASP.NET Core Sample Metrics

Troubleshooting

Metrics not appearing

Check that OTEL_EXPORTER_OTLP_ENDPOINT is reachable from your application host. Look for OpenTelemetry startup messages in the application logs — the SDK logs the endpoint and exporter configuration at startup.

Metrics delayed

The default export interval is 60 seconds. Reduce it for faster feedback during development:

OTEL_METRIC_EXPORT_INTERVAL=10000

Authentication errors

Verify the header is exactly signoz-ingestion-key=<your-key> with no extra spaces or quotes.

Metric aspnetcore.memory_pool.* not appearing

These metrics require .NET 10+ and only emit when Kestrel reads request bodies. Add POST endpoints that read req.Body to trigger them.

Next steps

Last updated: May 16, 2026

Edit on GitHub

Was this page helpful?

Your response helps us improve this page.