diff --git a/cmd/server/routes.go b/cmd/server/routes.go index 8844107..b1c84c8 100644 --- a/cmd/server/routes.go +++ b/cmd/server/routes.go @@ -425,7 +425,7 @@ func (s *Server) handlePerf(w http.ResponseWriter, r *http.Request) { sorted := sortedCopy(ep.Recent) d := &EndpointStatsResp{ Count: ep.Count, - AvgMs: round(ep.TotalMs/float64(ep.Count), 1), + AvgMs: safeAvg(ep.TotalMs, float64(ep.Count)), P50Ms: round(percentile(sorted, 0.5), 1), P95Ms: round(percentile(sorted, 0.95), 1), MaxMs: round(ep.MaxMs, 1), diff --git a/cmd/server/routes_test.go b/cmd/server/routes_test.go index 5676d91..8daa3e0 100644 --- a/cmd/server/routes_test.go +++ b/cmd/server/routes_test.go @@ -397,7 +397,7 @@ func TestPerfEndpoint(t *testing.T) { if !ok { t.Fatal("expected goRuntime object in perf response") } - for _, field := range []string{"heapMB", "sysMB", "numGoroutine", "numGC", "gcPauseMs"} { + for _, field := range []string{"goroutines", "numGC", "pauseTotalMs", "lastPauseMs", "heapAllocMB", "heapSysMB", "heapInuseMB", "heapIdleMB", "numCPU"} { if _, ok := goRuntime[field]; !ok { t.Errorf("expected %s in goRuntime", field) } diff --git a/cmd/server/testdata/golden/shapes.json b/cmd/server/testdata/golden/shapes.json index ade0f69..d04e74e 100644 --- a/cmd/server/testdata/golden/shapes.json +++ b/cmd/server/testdata/golden/shapes.json @@ -168,13 +168,18 @@ "type": "array", "elementShape": { "type": "object", - "dynamicKeys": true, - "valueShape": { - "type": "number" - }, - "requiredKeys": { + "keys": { "hour": { "type": "string" + }, + "1": { + "type": "number" + }, + "2": { + "type": "number" + }, + "3": { + "type": "number" } } } @@ -1483,19 +1488,31 @@ "goRuntime": { "type": "object", "keys": { - "heapMB": { - "type": "number" - }, - "sysMB": { - "type": "number" - }, - "numGoroutine": { + "goroutines": { "type": "number" }, "numGC": { "type": "number" }, - "gcPauseMs": { + "pauseTotalMs": { + "type": "number" + }, + "lastPauseMs": { + "type": "number" + }, + "heapAllocMB": { + "type": "number" + }, + "heapSysMB": { + "type": "number" + }, + "heapInuseMB": { + "type": "number" + }, + "heapIdleMB": { + "type": "number" + }, + "numCPU": { "type": "number" } } diff --git a/cmd/server/websocket_test.go b/cmd/server/websocket_test.go index 5e63beb..0ae6988 100644 --- a/cmd/server/websocket_test.go +++ b/cmd/server/websocket_test.go @@ -179,8 +179,8 @@ func TestBroadcastFullBuffer(t *testing.T) { func TestBroadcastMarshalError(t *testing.T) { hub := NewHub() - // Marshal error: channels can't be marshaled - hub.Broadcast(make(chan int)) + // Marshal error: functions can't be marshaled to JSON + hub.Broadcast(map[string]interface{}{"bad": func() {}}) // Should not panic — just log and return }