mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-11 14:53:49 +00:00
20 lines
354 B
Go
20 lines
354 B
Go
package streamaggr
|
|
|
|
type avgAggrValue struct {
|
|
sum float64
|
|
count float64
|
|
}
|
|
|
|
func (sv *avgAggrValue) pushSample(ctx *pushSampleCtx) {
|
|
sv.sum += ctx.sample.value
|
|
sv.count++
|
|
}
|
|
|
|
func (sv *avgAggrValue) flush(ctx *flushCtx, key string) {
|
|
if sv.count > 0 {
|
|
avg := sv.sum / sv.count
|
|
ctx.appendSeries(key, "avg", avg)
|
|
sv.sum = 0
|
|
sv.count = 0
|
|
}
|
|
}
|