Overview
Silky integrates MiniProfiler to provide real-time profiling of HTTP requests — including RPC timing, database queries, and cache hits. Use it in development and staging environments to quickly identify performance bottlenecks.
Installation
<PackageReference Include="Silky.Http.MiniProfiler" Version="3.9.2" />
Setup
Module Reference
[DependsOn(
typeof(MiniProfilerModule),
typeof(GatewayHostModule)
)]
public class GatewayModule : SilkyModule { }
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddSilkyHttpCore()
.AddSilkyMiniProfiler(); // adds MiniProfiler services
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment() || env.IsStaging())
{
app.UseMiniProfiler(); // serves /mini-profiler-resources/**
}
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "API V1");
c.IndexStream = () =>
typeof(Startup).Assembly
.GetManifestResourceStream(
"GatewayHost.wwwroot.swagger.index.html");
// Use the built-in index template that injects MiniProfiler widget
});
app.UseSilkyRpcProxy();
}
MiniProfiler in Swagger UI
Silky provides a customized Swagger index template that automatically injects the MiniProfiler widget into the Swagger UI. After calling app.UseMiniProfiler(), open the Swagger UI — a profiling widget appears in the top-left corner showing timing for the last request.
Profiling RPC Calls
When MiniProfiler is enabled, each RPC call made through the gateway is timed and appears in the profiler trace:
GET /api/order/1 42ms total
└─ RPC: IOrderAppService.GetAsync 38ms
└─ EFCore query 12ms
Configuration
{
"miniProfiler": {
"enabled": true,
"colorScheme": "Light",
"routeBasePath": "/mini-profiler-resources",
"maxUnviewedProfiles": 20,
"popupStartHidden": false
}
}
Warning
Enable MiniProfiler only in non-production environments. It adds per-request overhead and exposes internal timing details.
