RuntimeLens 1.0.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package RuntimeLens --version 1.0.0
                    
NuGet\Install-Package RuntimeLens -Version 1.0.0
                    
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" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RuntimeLens" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="RuntimeLens" />
                    
Project file
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 --version 1.0.0
                    
#r "nuget: RuntimeLens, 1.0.0"
                    
#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@1.0.0
                    
#: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&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=RuntimeLens&version=1.0.0
                    
Install as a Cake Tool

RuntimeLens

NuGet Version License

RuntimeLens is a high-performance runtime diagnostics and observability platform for .NET applications. It helps developers understand application behavior, track execution bottlenecks, inspect memory allocations, analyze GC spikes, and troubleshoot production issues โ€” all with zero application downtime and minimal configuration.


Why RuntimeLens?

Feature Description
โšก Near-Zero Overhead Built on System.Threading.Channels, Span<T>, ValueTask, and ArrayPool for minimal runtime footprint.
๐Ÿ’พ Persistent Storage Choose between in-memory ring-buffer (InMemory) or persistent JSON file storage (File) that survives application restarts.
๐ŸŽฏ Declarative Profiling Profile controller actions with [ProfileMethod] attribute โ€” no boilerplate code required.
๐Ÿ“Š Embedded Dashboard Self-contained web UI with zero CDN dependencies, dark/light themes, and server-driven localization (TR/EN).
๐Ÿšจ Smart Alerts Automated detection for slow requests, memory spikes, and GC collection spikes with deduplicated parent-child alert counting.
๐Ÿงน Noise Filtering 3-tier automatic filter excluding Chrome DevTools, favicons, Hot Reload, BrowserLink, and source map requests.
๐ŸŒณ Call Tree & Flame Graph Interactive execution hierarchy with thread info, tags, and metadata display.
๐Ÿ” Global Search Instant trace searching by operation, trace ID, category, tags, or exception messages.
๐Ÿ“ค Multi-Format Export Non-blocking JSON and 14-column aligned CSV trace exports.
๐Ÿ›ก๏ธ NativeAOT & Trimming Full trimming-friendly APIs with System.Text.Json source generation support.
๐Ÿ”Œ Plugin Architecture Extensible IPlugin lifecycle hooks for custom trace processing pipelines.
๐Ÿ”‘ Scoped Authentication Optional Basic Auth that applies exclusively to dashboard endpoints.

NuGet Packages

Package Description Target Frameworks
RuntimeLens Core telemetry engine, storage providers, analysis rules, and export providers. netstandard2.0, net8.0, net9.0, net10.0
RuntimeLens.Abstractions Shared interfaces (IRuntimeLens, ISpanScope, IStorageProvider, IPlugin) and data models. netstandard2.0, net8.0, net9.0, net10.0
RuntimeLens.AspNetCore ASP.NET Core middleware, DI extensions, [ProfileMethod] action filter, and DiagnosticSource listener. net8.0, net9.0, net10.0
RuntimeLens.Dashboard Embedded web dashboard UI, REST API endpoints, localization, and Basic Auth middleware. net8.0, net9.0, net10.0

Quick Start

Installation

# Core Telemetry & ASP.NET Core Integration
dotnet add package RuntimeLens.AspNetCore

# Embedded Web Dashboard
dotnet add package RuntimeLens.Dashboard

Minimal API Setup (Program.cs)

using RuntimeLens.AspNetCore.Extensions;
using RuntimeLens.Dashboard.Extensions;
using RuntimeLens.Options;

var builder = WebApplication.CreateBuilder(args);

// 1. Register RuntimeLens core telemetry & storage
builder.Services.AddRuntimeLens(options =>
{
    options.EnableDashboard = true;
    options.EnableSqlTracking = true;
    options.EnableHttpTracking = true;
    options.EnableMemoryTracking = true;
    options.EnableGcTracking = true;

    // Storage: InMemory (default) or File (survives restarts)
    options.Storage.Mode = StorageMode.File;
    options.Storage.FilePath = "runtimelens-traces.json";
    options.Storage.MaxSnapshotsInMemory = 5000;

    options.Sampling.Rate = 1.0;                   // 100% sampling
    options.Filters.SlowRequestThresholdMs = 500;   // Slow request alert threshold
    options.Filters.TrackDashboardRequests = false;  // Exclude self-profiling
    options.Filters.IgnoreNamespace("Microsoft");    // Exclude framework namespaces
});

// 2. Register RuntimeLens Dashboard UI
builder.Services.AddRuntimeLensDashboard(options =>
{
    options.RoutePrefix = "/runtimelens";   // Dashboard URL path
    options.DefaultLanguage = "en";         // "tr" for Turkish, "en" for English
    options.DefaultTheme = "dark";          // "dark" or "light"
    options.UseUtcTimestamp = true;          // UTC or local browser time

    // Scoped Basic Authentication (applies ONLY to /runtimelens endpoints)
    options.Authentication.Enabled = false;
    options.Authentication.Username = "admin";
    options.Authentication.Password = "SecretPassword123!";
});

var app = builder.Build();

app.UseRouting();
app.UseRuntimeLens();              // Enable telemetry middleware
app.UseRuntimeLensDashboard();     // Enable dashboard endpoints

app.MapGet("/api/order/{id}", async (int id, IRuntimeLens runtimeLens) =>
{
    using var scope = runtimeLens.StartScope("ProcessOrder", "BusinessLogic");
    scope.AddTag("order.id", id.ToString());

    await Task.Delay(50); // Simulate work
    return Results.Ok(new { OrderId = id, Status = "Processed" });
});

app.Run();

After starting the application, navigate to http://localhost:5000/runtimelens to open the dashboard.


Declarative Method Profiling

Decorate controller actions or services with [ProfileMethod] to automatically profile execution time, memory allocations, and exceptions:

using Microsoft.AspNetCore.Mvc;
using RuntimeLens.AspNetCore.Filters;

[ApiController]
[Route("api/[controller]")]
public class OrdersController : ControllerBase
{
    [HttpGet("{id}")]
    [ProfileMethod("GetOrderById", "API")]
    public IActionResult GetOrder(int id)
    {
        return Ok(new { Id = id, Amount = 250.00 });
    }
}

Manual Profiling & Custom Tags

Add manual spans, custom key-value tags, and metrics anywhere in your codebase:

public class PaymentService
{
    private readonly IRuntimeLens _runtimeLens;

    public PaymentService(IRuntimeLens runtimeLens)
    {
        _runtimeLens = runtimeLens;
    }

    public async Task ProcessPaymentAsync(string orderId, decimal amount)
    {
        using var scope = _runtimeLens.StartScope("ProcessPayment", "PaymentGateway");

        // Tags are rendered as interactive badges in the dashboard
        scope.AddTag("payment.order_id", orderId);
        scope.AddTag("payment.amount", amount.ToString("C"));
        scope.AddTag("gateway.provider", "Stripe");

        // Record custom metrics
        scope.RecordMetric("payment_amount", (double)amount, "USD");

        try
        {
            await Task.Delay(100); // Simulate API call
        }
        catch (Exception ex)
        {
            _runtimeLens.TrackException(ex);
            throw;
        }
    }
}

Automatic Noise Filtering

RuntimeLens includes a built-in 3-tier noise filter (NoiseFilter) that automatically excludes irrelevant requests from trace collection:

Tier Filtered Patterns
Chrome/Edge DevTools /.well-known/, com.chrome.devtools, chrome-extension://, moz-extension://
Favicons & Browser Icons /favicon, *.ico, apple-touch-icon, android-chrome
Hot Reload & Dev Tools /getScriptTag, /browserLink, /vs/browserlink, /aspnetcore-browser-refresh
Source Maps *.map, *.css.map, *.js.map

Noise filtering is applied at the middleware level (incoming HTTP), the DiagnosticSource listener (outgoing HTTP), and the file storage provider (persistence load).


Diagnostic Alert Rules

RuntimeLens ships with three built-in diagnostic alert rules that evaluate every captured trace:

Rule ID Rule Name Trigger Condition Severity
RL001 Slow Request Detection DurationMs > 500ms (configurable) โš ๏ธ Warning / ๐Ÿ”ด Critical (>1500ms)
RL002 High Memory Allocation MemoryAllocatedBytes > 10 MB โš ๏ธ Warning
RL003 High GC Trigger Rate Gen2 > 0 or Gen1 > 2 per span โš ๏ธ Warning / ๐Ÿ”ด Critical (Gen2)

Alerts are automatically deduplicated by TraceId + RuleName to prevent parent-child span double counting.


Configuration Reference

RuntimeLensOptions

Property Type Default Description
EnableDashboard bool true Enables/disables dashboard integration.
EnableSqlTracking bool true Tracks SQL queries via DiagnosticListener.
EnableHttpTracking bool true Tracks outgoing HttpClient calls via DiagnosticListener.
EnableRedisTracking bool true Tracks Redis commands via DiagnosticListener.
EnableMemoryTracking bool true Tracks byte allocations per span via GC.GetAllocatedBytesForCurrentThread().
EnableGcTracking bool true Tracks Gen 0/1/2 collection counts per span.

SamplingOptions

Property Type Default Description
Rate double 1.0 Sampling probability (1.0 = 100%, 0.1 = 10%).

StorageOptions

Property Type Default Description
Mode StorageMode InMemory InMemory (fast, transient) or File (persistent, survives restarts).
FilePath string "runtimelens-traces.json" JSON file path for persistent storage.
MaxSnapshotsInMemory int 5000 Maximum trace snapshots retained.
AutoFlushIntervalMs int 3000 Auto-flush interval for file storage (ms).

FilterOptions

Property Type Default Description
SlowRequestThresholdMs double 500.0 Threshold for slow request alerts and filters.
TrackDashboardRequests bool false If false, RuntimeLens dashboard requests are excluded from traces.
DashboardRoutePrefix string "/runtimelens" Route prefix for identifying self-profiling calls.
IgnoreNamespace(ns) method โ€” Excludes operations matching a namespace prefix.
IgnorePath(path) method โ€” Excludes HTTP requests matching a path prefix.

DashboardOptions

Property Type Default Description
RoutePrefix string "/runtimelens" HTTP route prefix for the dashboard UI & APIs.
DefaultLanguage string "en" Server-rendered UI language ("tr" or "en").
DefaultTheme string "dark" Initial theme ("dark" or "light").
UseUtcTimestamp bool true Format timestamps in UTC (true) or local browser time (false).

DashboardAuthenticationOptions

Property Type Default Description
Enabled bool false Enables Basic Authentication for dashboard routes only.
Username string "admin" Basic Auth username.
Password string "password" Basic Auth password.

Plugin Extensibility

Implement the IPlugin interface to hook into the trace processing lifecycle:

using RuntimeLens.Abstractions;
using RuntimeLens.Abstractions.Models;

public class SlackAlertPlugin : IPlugin
{
    public string Name => "SlackAlertPlugin";

    public ValueTask InitializeAsync(IRuntimeLens runtimeLens, CancellationToken ct = default)
    {
        // Setup logic
        return ValueTask.CompletedTask;
    }

    public async ValueTask OnTraceCapturedAsync(TraceSnapshot snapshot, CancellationToken ct = default)
    {
        if (snapshot.DurationMs > 2000)
        {
            // Send Slack notification for very slow requests
            await SendSlackMessageAsync($"โš ๏ธ Slow request: {snapshot.OperationName} ({snapshot.DurationMs:F0}ms)");
        }
    }
}

Dashboard Features

The embedded dashboard provides a rich diagnostic experience:

  • Overview Cards โ€” Total traces, average latency, active alerts, memory allocation summary
  • Trace Table โ€” Server-side paged query API (10, 25, 50, 100 per page) with sorting (Date, Duration, Memory)
  • Slow Query Filter โ€” ๐Ÿข Slow Only toggle for filtering slow operations
  • Auto-Refresh โ€” Configurable polling intervals (5s, 10s, 30s, 60s)
  • Trace Detail Modal โ€” Call tree hierarchy, flame graph, tags/metadata badges, thread info, exception details
  • Alert Modal โ€” Deduplicated alerts with severity indicators and View Trace โ†’ navigation links
  • Global Search โ€” Instant filtering by operation name, trace ID, category, tag keys/values, or exception messages
  • Dark/Light Theme โ€” User-toggleable theme with smooth transitions
  • JSON & CSV Export โ€” One-click download of all captured traces

REST API Endpoints

All endpoints are relative to the configured RoutePrefix (default: /runtimelens):

Endpoint Method Description
/{prefix} GET Serves the embedded dashboard HTML UI.
/{prefix}/api/overview GET Returns overview statistics (total traces, avg latency, active alerts, memory).
/{prefix}/api/traces GET Paginated trace query with search, sorting, and slow-only filtering.
/{prefix}/api/alerts GET Returns active diagnostic alerts with severity and trace correlation.
/{prefix}/api/export/json GET Downloads all traces as a JSON attachment.
/{prefix}/api/export/csv GET Downloads all traces as a 14-column CSV attachment.

Trace Query Parameters

Parameter Type Default Description
query string "" Search filter (operation name, trace ID, category, tags, exceptions).
page int 1 Page number.
pageSize int 25 Items per page (5โ€“100).
onlySlow bool false Filter only slow operations.
sortBy string "Date" Sort field: Date, Duration, or Memory.

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on RuntimeLens:

Package Downloads
RuntimeLens.AspNetCore

ASP.NET Core integration for RuntimeLens including telemetry middleware, DI extensions, [ProfileMethod] action filter, and DiagnosticSource tracking.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 135 7/20/2026
1.0.0 136 7/20/2026