From de3405c275898c8cd528a636dbd40e1b685cfaa5 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 13 May 2026 14:41:28 +0300 Subject: use errgroup instead of WaitGroup for concurrent snapshot builders Replace sync.WaitGroup with errgroup.Group in buildSubSnapshots so errors from sub-builders (buildSyscallSnapshots, buildFileSnapshots, buildProcessSnapshots, buildHistogramSnapshot) are captured and propagated rather than silently dropped. Change Engine.Snapshot() to return (*Snapshot, error), update runtime.SnapshotSource and dashboard.SnapshotSource interfaces accordingly, and adjust all callers in tui.go, dashboard/model.go, and the test helpers. Each sub-builder now returns (result, error); the error return is currently always nil but establishes the contract for future validation. The per-type Snapshot() convenience methods (histogram, syscall, file, process) panic on error since they are internal helpers where failure would be a programming bug. Co-Authored-By: Claude Sonnet 4.6 --- internal/runtime/runtime.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'internal/runtime/runtime.go') diff --git a/internal/runtime/runtime.go b/internal/runtime/runtime.go index d6500d4..e8e278e 100644 --- a/internal/runtime/runtime.go +++ b/internal/runtime/runtime.go @@ -38,8 +38,10 @@ type EventSink interface { // SnapshotSource provides statsengine snapshots for the TUI dashboard. // The core tracing engine passes a *statsengine.Engine; the TUI stores it // behind this interface so the dashboard can retrieve live snapshots. +// Snapshot returns (nil, nil) when the engine is nil. A non-nil error +// indicates that snapshot construction failed and the result must be discarded. type SnapshotSource interface { - Snapshot() *statsengine.Snapshot + Snapshot() (*statsengine.Snapshot, error) } // Snapshotter is the read-only subset of the trie contract used by consumers -- cgit v1.2.3