ASP.NET Core diagnostics
ApiLens
Why an ASP.NET Core request was slow or failed
NuvyntraLabs.NET.ApiLens · 0.1.0
Developer-first runtime diagnostics for ASP.NET Core. ApiLens reads System.Diagnostics and explains one request: endpoint time, EF Core commands, and outbound HttpClient calls. It does not replace OpenTelemetry, ASP.NET Core metrics, or a production observability backend.
Install
dotnet add package NuvyntraLabs.NET.ApiLens.AspNetCore
dotnet add package NuvyntraLabs.NET.ApiLens.EntityFrameworkCore
dotnet add package NuvyntraLabs.NET.ApiLens.HttpVersion 0.1.0 targets net10.0 and is on nuget.org. Publishing is pipeline-only. Do not dotnet nuget push from a local clone. Downloads for the five packages are on the .NET libraries NuGet stats.
Register
builder.Services.AddApiLens();
builder.Services.AddApiLensEntityFrameworkCore();
builder.Services.AddApiLensHttp();
app.UseApiLens();Call UseApiLens() before endpoints so the middleware wraps the request. Step-by-step: Getting started.
What a request shows
ApiLens stores a timeline for each MVC or minimal API request, attributes overlapping work as a share of wall-clock time, and flags a repeated SQL shape as a possible N+1. The dashboard is served only in Development. SQL parameter values, request bodies, response bodies, and HTTP query strings are never stored.
The time model and the N+1 rule are on the request timeline.
Capture
| Surface | Development | Production |
|---|---|---|
| Dashboard | On, unless EnableDashboard is false | Off |
| SQL text | Stored after literal redaction | Dropped after grouping |
| Parameter values | Never read | Never read |
| Request and response bodies | Never stored | Never stored |
| HTTP query strings | Not stored (host and status only) | Not stored |
| Exception text | Type name only | Type name only |
Packages
NuvyntraLabs.NET.ApiLensTimeline, attribution, N+1, explain rules, and the in-memory ring. No ASP.NET reference.
NuvyntraLabs.NET.ApiLens.AspNetCoreAddApiLens and UseApiLens for MVC and minimal APIs, plus the dashboard gate.
NuvyntraLabs.NET.ApiLens.EntityFrameworkCoreEF Core CommandExecuted and CommandError on the active request.
NuvyntraLabs.NET.ApiLens.HttpOutbound HttpClient timings. Factory clients use a handler. Other clients use the System.Net.Http diagnostic listener.
NuvyntraLabs.NET.ApiLens.UIEmbedded dashboard page. Referenced by the ASP.NET Core package.
Package boundaries: Packages.
Sample
dotnet run --project samples/ApiLens.SampleGET /api/orders runs a deliberate per-row query loop. The dashboard is at /_apilens.
Discussion
Comment on ApiLens. The thread lives on this component's GitHub repository. Sign in with GitHub — Giscus uses Discussions, Utterances uses Issues.
Issues are not enabled on this repository
Open the conversation on GitHub, or use the Giscus tab if Discussions are available.