Files
VictoriaMetrics/lib/streamaggr/count_samples.go
Andrii Chubatiuk c174a046e2 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

31 lines
646 B
Go

package streamaggr
type countSamplesAggrValue struct {
count uint64
}
func (av *countSamplesAggrValue) pushSample(_ aggrConfig, _ *pushSample, _ string, _ int64) {
av.count++
}
func (av *countSamplesAggrValue) flush(_ aggrConfig, ctx *flushCtx, key string, _ bool) {
if av.count > 0 {
ctx.appendSeries(key, "count_samples", float64(av.count))
av.count = 0
}
}
func (*countSamplesAggrValue) state() any {
return nil
}
func newCountSamplesAggrConfig() aggrConfig {
return &countSamplesAggrConfig{}
}
type countSamplesAggrConfig struct{}
func (*countSamplesAggrConfig) getValue(_ any) aggrValue {
return &countSamplesAggrValue{}
}