Skip to main content
Version: Next

Profiler Panel

Sharkable provides a built-in lightweight profiler panel at /_sharkable/profiler (configurable). Tracks request counts, average latency, and the top-N slowest recent requests.

Quick Start

builder.Services.AddShark(opt =>
{
opt.ConfigureProfiler(p => p.TopSlowRequests = 10);
});

var app = builder.Build();
app.UseShark();

Navigate to /_sharkable/profiler:

{
"uptime": "02:34:12",
"totalRequests": 2847,
"avgLatencyMs": 12.3,
"topSlow": [
{
"method": "POST",
"path": "/api/orders/create",
"statusCode": 200,
"elapsedMs": 234,
"memoryDeltaBytes": 4096,
"at": "2026-06-28T14:30:00.0000000+00:00"
}
]
}

Configuration

opt.ConfigureProfiler(p =>
{
// Endpoint path. Default: "/_sharkable/profiler"
p.Endpoint = "/_sharkable/profiler";

// Max slow requests to track. Default: 20
p.TopSlowRequests = 10;

// Max ring buffer entries. Default: 1000
p.MaxEntries = 1000;

// Track per-request memory delta (calls GC.GetTotalMemory before/after).
// Disabled by default — adds GC bookkeeping overhead at high RPS.
p.TrackMemory = true;
});

Tracked Metrics

MetricDescription
uptimeApplication uptime since first request
totalRequestsTotal request count since startup
avgLatencyMsAverage response time in milliseconds
topSlowTop-N slowest recent requests (up to 1000 buffered)

Each slow request entry includes: HTTP method, path, status code, elapsed ms, memory delta (bytes), and timestamp.

Performance

  • Ring buffer limited to 1000 entries
  • Lock-free reads via ConcurrentQueue
  • Zero allocation overhead on the hot path
  • Profiler endpoint auto-excluded from OpenAPI/Scalar docs

Access Control

The profiler endpoint is not protected by default. In production, restrict access via middleware or environment checks:

if (app.Environment.IsDevelopment())
opt.ConfigureProfiler(p => { });