Skip to content

Commit d10435e

Browse files
authored
Report observation window counters (#109)
With this change each telemetry report will include the count of http requests, responses, rate limited requests, etc. during the observation window. These count get reset each time we report.
1 parent 713585b commit d10435e

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/OneOfOne/xxhash v1.2.8
88
github.com/Pallinder/go-randomdata v1.2.0
99
github.com/akitasoftware/akita-ir v0.0.0-20241213050034-057d7b6097e8
10-
github.com/akitasoftware/akita-libs v0.0.0-20250428180153-cb2e977a2ee3
10+
github.com/akitasoftware/akita-libs v0.0.0-20250430223533-06e05e3725df
1111
github.com/akitasoftware/go-utils v0.0.0-20240213133309-b95d4ace8803
1212
github.com/andybalholm/brotli v1.0.1
1313
github.com/aws/aws-sdk-go-v2 v1.17.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ github.com/akitasoftware/akita-libs v0.0.0-20250314233547-6ff5afce3bf6 h1:kuJ8kv
3434
github.com/akitasoftware/akita-libs v0.0.0-20250314233547-6ff5afce3bf6/go.mod h1:Fg14kX6+N7we3KdP1c11W/SzbKsgapV1hP5d4Z/Hqwc=
3535
github.com/akitasoftware/akita-libs v0.0.0-20250428180153-cb2e977a2ee3 h1:ANLqfVeDdlJoLf1jCjWlxtKaj65N8bLJ9OLmp1h8w/o=
3636
github.com/akitasoftware/akita-libs v0.0.0-20250428180153-cb2e977a2ee3/go.mod h1:Fg14kX6+N7we3KdP1c11W/SzbKsgapV1hP5d4Z/Hqwc=
37+
github.com/akitasoftware/akita-libs v0.0.0-20250430223533-06e05e3725df h1:NLeQdXerlr1FOXvVgwrYpAat2UeIFKyb+AmRlOz2otQ=
38+
github.com/akitasoftware/akita-libs v0.0.0-20250430223533-06e05e3725df/go.mod h1:Fg14kX6+N7we3KdP1c11W/SzbKsgapV1hP5d4Z/Hqwc=
3739
github.com/akitasoftware/go-utils v0.0.0-20240213133309-b95d4ace8803 h1:ebIh/EFuaP8GczzMe8EwVID/blSv5Tej6S8NE4xyarQ=
3840
github.com/akitasoftware/go-utils v0.0.0-20240213133309-b95d4ace8803/go.mod h1:+IOXf7l/QCAQECJzjJwhTp1sBkRoJ6WciZwJezUwBa4=
3941
github.com/akitasoftware/gopacket v1.1.18-0.20240820200020-7289ae956f70 h1:VnU7QLDBwRujpQoHwShs5yu0Ahv1fSalNJa4UijwlmY=

trace/stats.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ type PacketCountConsumer interface {
2121
}
2222

2323
// Discard the count
24-
type PacketCountDiscard struct {
25-
}
24+
type PacketCountDiscard struct{}
2625

2726
func (d *PacketCountDiscard) Update(_ PacketCounts) {
2827
}
@@ -37,10 +36,11 @@ func (d *PacketCountDiscard) Update(_ PacketCounts) {
3736
// Imposes a hard limit on the number of ports, interfaces, and hosts that
3837
// are individually tracked.
3938
type PacketCounter struct {
40-
total PacketCounts
41-
byPort *BoundedPacketCounter[int]
42-
byInterface *BoundedPacketCounter[string]
43-
mutex sync.RWMutex
39+
total PacketCounts
40+
observationWindow PacketCounts
41+
byPort *BoundedPacketCounter[int]
42+
byInterface *BoundedPacketCounter[string]
43+
mutex sync.RWMutex
4444

4545
// XXX(cns): Only counts HTTPRequest and TLSHello. Other metrics are not
4646
// easily tracked per-host.
@@ -127,6 +127,7 @@ func (s *PacketCounter) Update(c PacketCounts) {
127127
return new
128128
})
129129

130+
s.observationWindow.Add(c)
130131
s.total.Add(c)
131132
}
132133

@@ -210,11 +211,12 @@ func (s *PacketCounter) Summary(n int) *PacketCountSummary {
210211
}
211212

212213
return &PacketCountSummary{
213-
Version: Version,
214-
Total: s.total,
215-
TopByPort: topByPort,
216-
TopByInterface: topByInterface,
217-
TopByHost: topByHost,
214+
Version: Version,
215+
Total: s.total,
216+
ObservationWindow: *s.observationWindow.CopyAndReset(),
217+
TopByPort: topByPort,
218+
TopByInterface: topByInterface,
219+
TopByHost: topByHost,
218220

219221
ByPortOverflowLimit: maxKeys,
220222
ByInterfaceOverflowLimit: maxKeys,

0 commit comments

Comments
 (0)