Add support for timing sums in statsd input (#3234)
This commit is contained in:
committed by
Daniel Nelson
parent
f2294c7f2c
commit
3073221f7d
@@ -24,8 +24,10 @@ type RunningStats struct {
|
||||
perc []float64
|
||||
PercLimit int
|
||||
|
||||
upper float64
|
||||
sum float64
|
||||
|
||||
lower float64
|
||||
upper float64
|
||||
|
||||
// cache if we have sorted the list so that we never re-sort a sorted list,
|
||||
// which can have very bad performance.
|
||||
@@ -51,6 +53,9 @@ func (rs *RunningStats) AddValue(v float64) {
|
||||
rs.ex += v - rs.k
|
||||
rs.ex2 += (v - rs.k) * (v - rs.k)
|
||||
|
||||
// add to running sum
|
||||
rs.sum += v
|
||||
|
||||
// track upper and lower bounds
|
||||
if v > rs.upper {
|
||||
rs.upper = v
|
||||
@@ -78,6 +83,10 @@ func (rs *RunningStats) Stddev() float64 {
|
||||
return math.Sqrt(rs.Variance())
|
||||
}
|
||||
|
||||
func (rs *RunningStats) Sum() float64 {
|
||||
return rs.sum
|
||||
}
|
||||
|
||||
func (rs *RunningStats) Upper() float64 {
|
||||
return rs.upper
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user