From 031c4dd2c2ed38b161556f0ff3db8d4673c5a902 Mon Sep 17 00:00:00 2001 From: Kpa-clawbot <259247574+Kpa-clawbot@users.noreply.github.com> Date: Fri, 27 Mar 2026 21:38:13 -0700 Subject: [PATCH] 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> --- cmd/server/routes.go | 12 ++++++++---- cmd/server/types.go | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/cmd/server/routes.go b/cmd/server/routes.go index 7443144b..486d8c1e 100644 --- a/cmd/server/routes.go +++ b/cmd/server/routes.go @@ -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(), } }(), }) diff --git a/cmd/server/types.go b/cmd/server/types.go index 0edac5e6..176f21e4 100644 --- a/cmd/server/types.go +++ b/cmd/server/types.go @@ -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 ───────────────────────────────────────────────────────────────────