RuntimeLens.AspNetCore
1.0.1
Prefix Reserved
dotnet add package RuntimeLens.AspNetCore --version 1.0.1
NuGet\Install-Package RuntimeLens.AspNetCore -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RuntimeLens.AspNetCore" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RuntimeLens.AspNetCore" Version="1.0.1" />
<PackageReference Include="RuntimeLens.AspNetCore" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RuntimeLens.AspNetCore --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RuntimeLens.AspNetCore, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RuntimeLens.AspNetCore@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RuntimeLens.AspNetCore&version=1.0.1
#tool nuget:?package=RuntimeLens.AspNetCore&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
RuntimeLens.AspNetCore
ASP.NET Core integration for RuntimeLens providing request telemetry middleware, DI extensions, [ProfileMethod] action filter, and automated DiagnosticSource listeners.
Target Frameworks
.NET 8.0|.NET 9.0|.NET 10.0
Extension Methods & Attribute Reference
1. DI Service & Middleware Registration
| Method | Target | Description |
|---|---|---|
AddRuntimeLens(options => ...) |
IServiceCollection |
Registers IRuntimeLens, storage providers, and diagnostic listeners in DI. |
UseRuntimeLens() |
IApplicationBuilder |
Enables HTTP request telemetry middleware (place after UseRouting()). |
2. [ProfileMethod] Action Filter Attribute
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
public sealed class ProfileMethodAttribute : Attribute
{
public string? OperationName { get; } // Custom operation name (null = method name)
public string Category { get; } // Classification category tag (default: "Method")
public ProfileMethodAttribute(string? operationName = null, string category = "Method");
}
Automated Telemetry Listeners
- HTTP Request Middleware: Captures HTTP Method, Route Path, Status Code, Latency, Memory allocated, Client IP, and Query parameters.
- EF Core & SQL Listener: Intercepts
DiagnosticSourceevents fromMicrosoft.EntityFrameworkCoreandSystem.Data.SqlClient/Microsoft.Data.SqlClientto record SQL statements and latency. - Outgoing HttpClient Listener: Intercepts
System.Net.Httpoutgoing calls and appends child sub-spans. - Built-in Noise Filter: Excludes Chrome DevTools, Hot Reload (
/signalr), BrowserLink,/favicon.ico, and.mapsource map requests automatically.
Code Examples
1. ASP.NET Core Setup (Program.cs)
using RuntimeLens.AspNetCore.Extensions;
using RuntimeLens.Options;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
// Register RuntimeLens telemetry services in DI container
builder.Services.AddRuntimeLens(options =>
{
// Enable automated diagnostic listeners
options.EnableSqlTracking = true; // Intercept EF Core & SQL database queries
options.EnableHttpTracking = true; // Intercept incoming/outgoing HTTP calls
options.EnableMemoryTracking = true; // Track memory allocations per request
options.EnableGcTracking = true; // Track GC collections per request
// Configure storage backend (File-based persistence)
options.Storage.Mode = StorageMode.File;
options.Storage.FilePath = "runtimelens-web-traces.json";
options.Storage.MaxSnapshotsInMemory = 5000;
// Configure filtering & thresholds
options.Filters.SlowRequestThresholdMs = 400.0; // Slow threshold: 400ms
options.Filters.TrackDashboardRequests = false; // Ignore self-profiling dashboard routes
options.Filters.IgnorePath("/healthz"); // Ignore healthcheck endpoint
});
var app = builder.Build();
app.UseRouting();
// Enable RuntimeLens telemetry middleware (place AFTER UseRouting)
app.UseRuntimeLens();
app.MapControllers();
app.Run();
2. Controller Action Profiling ([ProfileMethod])
using Microsoft.AspNetCore.Mvc;
using RuntimeLens.Abstractions;
using RuntimeLens.AspNetCore.Filters;
[ApiController]
[Route("api/[controller]")]
public class ProductsController : ControllerBase
{
private readonly IRuntimeLens _lens;
public ProductsController(IRuntimeLens lens)
{
_lens = lens; // Inject telemetry engine
}
[HttpGet("{id}")]
[ProfileMethod("GetProductById", Category = "Catalog")] // Automated action method profiling
public async Task<IActionResult> GetProduct(int id)
{
// Attach custom diagnostic tags to current active action scope
_lens.AddTag("product.id", id.ToString());
// Create explicit child sub-span scope for specific internal operations
using (var cacheSpan = _lens.StartScope("CheckCache", category: "Cache"))
{
cacheSpan.AddTag("cache.key", $"product:{id}");
await Task.Delay(10); // Simulate cache lookup
} // Sub-span closed and attached to action trace tree
return Ok(new { Id = id, Name = "Sample Product" });
} // Action method completed and recorded automatically by ProfileMethodActionFilter
}
Learn More
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- RuntimeLens (>= 1.0.1)
-
net8.0
- RuntimeLens (>= 1.0.1)
-
net9.0
- RuntimeLens (>= 1.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on RuntimeLens.AspNetCore:
| Package | Downloads |
|---|---|
|
RuntimeLens.Dashboard
Embedded web dashboard UI, visual trace explorer, flame graph visualizer, real-time performance metrics, localization (TR/EN), and Basic Auth for RuntimeLens. |
GitHub repositories
This package is not used by any popular GitHub repositories.