blob: 03dad5d4679ab43fa30197bc0a5b6c61f9f379c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package statsengine
import "ior/internal/types"
// SyscallAggregate is the kernel-side aggregate for one sys_enter trace ID.
type SyscallAggregate struct {
TraceID types.TraceId
Count uint64
Errors uint64
TotalLatencyNs uint64
MinLatencyNs uint64
MaxLatencyNs uint64
LatencyHistogramNs [8]uint64
}
// IngestSyscallAggregates folds kernel aggregate rows into the engine.
func (e *Engine) IngestSyscallAggregates(rows []SyscallAggregate) {
if e == nil || len(rows) == 0 {
return
}
e.mu.Lock()
defer e.mu.Unlock()
now := e.now()
var batchLatency uint64
var batchCount uint64
for _, row := range rows {
if row.Count == 0 {
continue
}
e.totalSyscalls += row.Count
e.totalErrors += row.Errors
e.totalLatency += row.TotalLatencyNs
e.syscalls.AddAggregate(row)
e.families.AddAggregate(row)
e.latencyHist.AddBucketCounts(row.LatencyHistogramNs)
batchLatency += row.TotalLatencyNs
batchCount += row.Count
}
if batchCount > 0 {
e.latencySeries.Add(float64(batchLatency)/float64(batchCount), now)
}
}
|