Skip to content

Commit

Permalink
Round saturation to 2dp to report integer percentages
Browse files Browse the repository at this point in the history
  • Loading branch information
boxofrad committed Feb 10, 2022
1 parent bc5e8d8 commit f8ea87a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions saturation.go
@@ -1,6 +1,7 @@
package raft

import (
"math"
"time"

"github.com/armon/go-metrics"
Expand Down Expand Up @@ -128,11 +129,12 @@ func (s *saturationMetric) report() {

total := now.Sub(beginning) - lost

var saturation float32
var saturation float64
if total != 0 {
saturation = float32(total-slept) / float32(total)
saturation = float64(total-slept) / float64(total)
saturation = math.Round(saturation*100) / 100
}
s.reportFn(saturation)
s.reportFn(float32(saturation))

s.currentBucket++
if s.currentBucket >= len(s.buckets) {
Expand Down

0 comments on commit f8ea87a

Please sign in to comment.