2023-01-04 06:19:18 +00:00
|
|
|
package streamaggr
|
|
|
|
|
2024-09-24 20:03:04 +00:00
|
|
|
type lastAggrValue struct {
|
2024-03-17 23:02:28 +00:00
|
|
|
last float64
|
|
|
|
timestamp int64
|
2023-01-04 06:19:18 +00:00
|
|
|
}
|
|
|
|
|
2024-09-24 20:03:04 +00:00
|
|
|
func (av *lastAggrValue) pushSample(ctx *pushSampleCtx) {
|
|
|
|
if ctx.sample.timestamp >= av.timestamp {
|
|
|
|
av.last = ctx.sample.value
|
|
|
|
av.timestamp = ctx.sample.timestamp
|
2023-01-04 06:19:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-24 20:03:04 +00:00
|
|
|
func (av *lastAggrValue) flush(ctx *flushCtx, key string) {
|
|
|
|
if av.timestamp > 0 {
|
|
|
|
ctx.appendSeries(key, "last", av.last)
|
|
|
|
av.timestamp = 0
|
|
|
|
}
|
2023-01-04 06:19:18 +00:00
|
|
|
}
|