Files
Andrii ChubatiukandGitHub 702af1764c 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/).
2025-03-10 13:50:55 +01:00

35 lines
679 B
Go

package streamaggr
type lastAggrValue struct {
last float64
timestamp int64
}
func (av *lastAggrValue) pushSample(_ aggrConfig, sample *pushSample, _ string, _ int64) {
if sample.timestamp >= av.timestamp {
av.last = sample.value
av.timestamp = sample.timestamp
}
}
func (av *lastAggrValue) flush(_ aggrConfig, ctx *flushCtx, key string, _ bool) {
if av.timestamp > 0 {
ctx.appendSeries(key, "last", av.last)
av.timestamp = 0
}
}
func (*lastAggrValue) state() any {
return nil
}
func newLastAggrConfig() aggrConfig {
return &lastAggrConfig{}
}
type lastAggrConfig struct{}
func (*lastAggrConfig) getValue(_ any) aggrValue {
return &lastAggrValue{}
}