mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00

### 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
)
37 lines
682 B
Go
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{}
|
|
}
|