summaryrefslogtreecommitdiff
path: root/internal/statsengine/syscall.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-20 11:38:19 +0300
committerPaul Buetow <paul@buetow.org>2026-05-20 11:38:19 +0300
commit9310b54d439d4a1a8d4d337987aa63884df0af76 (patch)
treec6fb38085891a04ce81672f977af316a2e96b2fd /internal/statsengine/syscall.go
parent5fd613562e2aa2ab3aac3349f44db88330046c1c (diff)
feat: add syscall aggregate sampling infrastructure (task 17)
Diffstat (limited to 'internal/statsengine/syscall.go')
-rw-r--r--internal/statsengine/syscall.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/statsengine/syscall.go b/internal/statsengine/syscall.go
index d58e8c9..5c85b2a 100644
--- a/internal/statsengine/syscall.go
+++ b/internal/statsengine/syscall.go
@@ -99,6 +99,29 @@ func (a *syscallAccumulator) Add(pair *event.Pair) {
}
}
+func (a *syscallAccumulator) AddAggregate(row SyscallAggregate) {
+ if a == nil || row.TraceID == 0 || row.Count == 0 {
+ return
+ }
+
+ stats := a.byID[row.TraceID]
+ if stats == nil {
+ stats = &syscallStats{traceID: row.TraceID, name: row.TraceID.Name()}
+ a.byID[row.TraceID] = stats
+ }
+
+ prevCount := stats.count
+ stats.count += row.Count
+ stats.errorCount += row.Errors
+ stats.totalLatency += row.TotalLatencyNs
+ if prevCount == 0 || row.MinLatencyNs < stats.minLatency {
+ stats.minLatency = row.MinLatencyNs
+ }
+ if row.MaxLatencyNs > stats.maxLatency {
+ stats.maxLatency = row.MaxLatencyNs
+ }
+}
+
// Snapshot returns a slice of SyscallSnapshots for all tracked syscalls.
// It panics on build error, which should never happen for a valid accumulator.
func (a *syscallAccumulator) Snapshot(elapsed time.Duration) []SyscallSnapshot {