summaryrefslogtreecommitdiff
path: root/internal/statsengine/family.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/family.go
parent5fd613562e2aa2ab3aac3349f44db88330046c1c (diff)
feat: add syscall aggregate sampling infrastructure (task 17)
Diffstat (limited to 'internal/statsengine/family.go')
-rw-r--r--internal/statsengine/family.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/statsengine/family.go b/internal/statsengine/family.go
index 3206d57..a97332d 100644
--- a/internal/statsengine/family.go
+++ b/internal/statsengine/family.go
@@ -59,6 +59,30 @@ func (a *familyAccumulator) Add(pair *event.Pair) {
}
}
+func (a *familyAccumulator) AddAggregate(row SyscallAggregate) {
+ if a == nil || row.TraceID == 0 || row.Count == 0 {
+ return
+ }
+
+ family := row.TraceID.Family()
+ stats := a.byFamily[family]
+ if stats == nil {
+ stats = &familyStats{family: family}
+ a.byFamily[family] = 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
+ }
+}
+
func (a *familyAccumulator) snapshotInputs() []familySnapshotInput {
if a == nil {
return nil