VictoriaMetrics/lib/streamaggr/min.go
Andrii Chubatiuk 394654c127
lib/streamaggr: fixed streamaggr panic (#8471)
### Describe Your Changes

fixes #8469

### Checklist

The following checks are **mandatory**:

- [ ] My change adheres [VictoriaMetrics contributing
guidelines](https://docs.victoriametrics.com/contributing/).

(cherry picked from commit c174a046e2)
2025-03-10 13:54:23 +01:00

37 lines
682 B
Go

package streamaggr
type minAggrValue struct {
min float64
defined bool
}
func (av *minAggrValue) pushSample(_ aggrConfig, sample *pushSample, _ string, _ int64) {
if sample.value < av.min || !av.defined {
av.min = sample.value
}
if !av.defined {
av.defined = true
}
}
func (av *minAggrValue) flush(_ aggrConfig, ctx *flushCtx, key string, _ bool) {
if av.defined {
ctx.appendSeries(key, "min", av.min)
av.min = 0
av.defined = false
}
}
func (*minAggrValue) state() any {
return nil
}
func newMinAggrConfig() aggrConfig {
return &minAggrConfig{}
}
type minAggrConfig struct{}
func (*minAggrConfig) getValue(_ any) aggrValue {
return &minAggrValue{}
}