feat: execute full-repo remaining parity closure plan
This commit is contained in:
@@ -21,6 +21,7 @@ public sealed class MonitorServer : IAsyncDisposable
|
||||
private readonly GatewayzHandler _gatewayzHandler;
|
||||
private readonly LeafzHandler _leafzHandler;
|
||||
private readonly AccountzHandler _accountzHandler;
|
||||
private readonly PprofHandler _pprofHandler;
|
||||
|
||||
public MonitorServer(NatsServer server, NatsOptions options, ServerStats stats, ILoggerFactory loggerFactory)
|
||||
{
|
||||
@@ -41,6 +42,7 @@ public sealed class MonitorServer : IAsyncDisposable
|
||||
_gatewayzHandler = new GatewayzHandler(server);
|
||||
_leafzHandler = new LeafzHandler(server);
|
||||
_accountzHandler = new AccountzHandler(server);
|
||||
_pprofHandler = new PprofHandler();
|
||||
|
||||
_app.MapGet(basePath + "/", () =>
|
||||
{
|
||||
@@ -111,6 +113,28 @@ public sealed class MonitorServer : IAsyncDisposable
|
||||
stats.HttpReqStats.AddOrUpdate("/jsz", 1, (_, v) => v + 1);
|
||||
return Results.Ok(_jszHandler.Build());
|
||||
});
|
||||
|
||||
if (options.ProfPort > 0)
|
||||
{
|
||||
_app.MapGet(basePath + "/debug/pprof", () =>
|
||||
{
|
||||
stats.HttpReqStats.AddOrUpdate("/debug/pprof", 1, (_, v) => v + 1);
|
||||
return Results.Text(_pprofHandler.Index(), "text/plain");
|
||||
});
|
||||
|
||||
_app.MapGet(basePath + "/debug/pprof/profile", (HttpContext ctx) =>
|
||||
{
|
||||
stats.HttpReqStats.AddOrUpdate("/debug/pprof/profile", 1, (_, v) => v + 1);
|
||||
var seconds = 30;
|
||||
if (ctx.Request.Query.TryGetValue("seconds", out var values)
|
||||
&& int.TryParse(values.ToString(), out var parsed))
|
||||
{
|
||||
seconds = parsed;
|
||||
}
|
||||
|
||||
return Results.File(_pprofHandler.CaptureCpuProfile(seconds), "application/octet-stream");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public async Task StartAsync(CancellationToken ct)
|
||||
|
||||
Reference in New Issue
Block a user