fix: goRuntime perf fields match frontend expectations (goroutines, heapAllocMB, etc.)

Frontend reads goroutines/pauseTotalMs/lastPauseMs/heapAllocMB/heapSysMB/
heapInuseMB/heapIdleMB/numCPU but Go was returning heapMB/sysMB/numGoroutine/
gcPauseMs. All showed as undefined.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Kpa-clawbot
2026-03-27 21:38:13 -07:00
co-authored by Copilot
parent d9523f23a0
commit 031c4dd2c2
2 changed files with 16 additions and 8 deletions
+8 -4
View File
@@ -495,11 +495,15 @@ func (s *Server) handlePerf(w http.ResponseWriter, r *http.Request) {
GoRuntime: func() *GoRuntimeStats {
ms := s.getMemStats()
return &GoRuntimeStats{
HeapMB: float64(ms.HeapAlloc) / 1024 / 1024,
SysMB: float64(ms.Sys) / 1024 / 1024,
NumGoroutine: runtime.NumGoroutine(),
Goroutines: runtime.NumGoroutine(),
NumGC: ms.NumGC,
GCPauseMs: float64(ms.PauseNs[(ms.NumGC+255)%256]) / 1e6,
PauseTotalMs: float64(ms.PauseTotalNs) / 1e6,
LastPauseMs: float64(ms.PauseNs[(ms.NumGC+255)%256]) / 1e6,
HeapAllocMB: float64(ms.HeapAlloc) / 1024 / 1024,
HeapSysMB: float64(ms.HeapSys) / 1024 / 1024,
HeapInuseMB: float64(ms.HeapInuse) / 1024 / 1024,
HeapIdleMB: float64(ms.HeapIdle) / 1024 / 1024,
NumCPU: runtime.NumCPU(),
}
}(),
})
+8 -4
View File
@@ -211,11 +211,15 @@ type PerfResponse struct {
// GoRuntimeStats holds Go runtime metrics for the perf endpoint.
type GoRuntimeStats struct {
HeapMB float64 `json:"heapMB"`
SysMB float64 `json:"sysMB"`
NumGoroutine int `json:"numGoroutine"`
Goroutines int `json:"goroutines"`
NumGC uint32 `json:"numGC"`
GCPauseMs float64 `json:"gcPauseMs"`
PauseTotalMs float64 `json:"pauseTotalMs"`
LastPauseMs float64 `json:"lastPauseMs"`
HeapAllocMB float64 `json:"heapAllocMB"`
HeapSysMB float64 `json:"heapSysMB"`
HeapInuseMB float64 `json:"heapInuseMB"`
HeapIdleMB float64 `json:"heapIdleMB"`
NumCPU int `json:"numCPU"`
}
// ─── Packets ───────────────────────────────────────────────────────────────────