align bucket boundary to interval in rolling window (#345)

This commit is contained in:
Kevin Wan
2021-01-04 11:17:59 +08:00
committed by GitHub
parent efa43483b2
commit 0786862a35
2 changed files with 8 additions and 1 deletions

View File

@@ -96,7 +96,9 @@ func (rw *RollingWindow) updateOffset() {
}
rw.offset = (offset + span) % rw.size
rw.lastTime = rw.lastTime + rw.interval*time.Duration(span)
now := timex.Now()
// align to interval time boundary
rw.lastTime = now - (now-rw.lastTime)%rw.interval
}
type Bucket struct {