mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 00:26:36 +03:00
### Describe Your Changes fixes #8469 ### Checklist The following checks are **mandatory**: - [ ] My change adheres [VictoriaMetrics contributing guidelines](https://docs.victoriametrics.com/contributing/).
38 lines
682 B
Go
38 lines
682 B
Go
package streamaggr
|
|
|
|
type maxAggrValue struct {
|
|
max float64
|
|
defined bool
|
|
}
|
|
|
|
func (av *maxAggrValue) pushSample(_ aggrConfig, sample *pushSample, _ string, _ int64) {
|
|
if sample.value > av.max || !av.defined {
|
|
av.max = sample.value
|
|
}
|
|
if !av.defined {
|
|
av.defined = true
|
|
}
|
|
}
|
|
|
|
func (av *maxAggrValue) flush(_ aggrConfig, ctx *flushCtx, key string, _ bool) {
|
|
if av.defined {
|
|
ctx.appendSeries(key, "max", av.max)
|
|
av.max = 0
|
|
av.defined = false
|
|
}
|
|
}
|
|
|
|
func (*maxAggrValue) state() any {
|
|
return nil
|
|
}
|
|
|
|
func newMaxAggrConfig() aggrConfig {
|
|
return &maxAggrConfig{}
|
|
}
|
|
|
|
type maxAggrConfig struct{}
|
|
|
|
func (*maxAggrConfig) getValue(_ any) aggrValue {
|
|
return &maxAggrValue{}
|
|
}
|