Skip to content

Commit

Permalink
Hot fix time window traffic collector (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanliqun authored Aug 2, 2024
1 parent 883091f commit 5c99dd1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions util/metrics/traffics.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,12 @@ func (tc *timeWindowTrafficCollector) TopkVisitors(k int) []Visitor {
return nil
}

topkHeap := topkVisitorHeap(make([]*visitorItem, 0, k+1))
tdata := tc.window.Data().(twTrafficData)
tdata, ok := tc.window.Data().(twTrafficData)
if !ok { // no data
return nil
}

topkHeap := topkVisitorHeap(make([]*visitorItem, 0, k+1))
for src, hits := range tdata.data {
vi := &visitorItem{
Visitor: Visitor{Source: src, Hits: hits},
Expand Down

0 comments on commit 5c99dd1

Please sign in to comment.