Skip to content

Commit

Permalink
Send correct hit rate metric when no events have occurred (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramyahasini authored Sep 2, 2020
1 parent 5f17676 commit 192e8e5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/graphite.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,13 @@ func (m *Metrics) parseBPFLine(tokens []string, probeName string) (*bpfMetrics,
m.missedCount[probeName] = currentMiss
m.mux.Unlock()
// Send hit/miss rates instead of value
hitRate = float64(hitValue)
missedRate = float64(missedValue)
if hitValue != 0 || missedValue != 0 {
hitRate = float64(hitValue) / float64(hitValue+missedValue)
missedRate = float64(missedValue) / float64(hitValue+missedValue)
} else {
// Hit/Miss rates are 0, meaning no new events occurred, send hitRate 1
hitRate = float64(1)
missedRate = float64(missedValue)
}
return &bpfMetrics{
hitRate: hitRate,
Expand Down

0 comments on commit 192e8e5

Please sign in to comment.