fix(aggregators): Handle time drift when calculating aggregation windows (#16375)
Co-authored-by: Joachim DB Systel <joachim.schachermayer@deutschebahn.com>
This commit is contained in:
parent
e5a9309451
commit
52244af2b6
|
|
@ -177,6 +177,17 @@ func (r *RunningAggregator) Push(acc telegraf.Accumulator) {
|
|||
|
||||
since := r.periodEnd
|
||||
until := r.periodEnd.Add(r.Config.Period)
|
||||
|
||||
// Check if the next aggregation window will contain "now". This might
|
||||
// not be the case if the machine's clock was adjusted or the machine
|
||||
// hibernated as in those cases the clock might be advanced before or
|
||||
// after the initial aggregation window.
|
||||
nowWall := time.Now().Truncate(-1)
|
||||
if nowWall.Before(since.Truncate(-1)) || nowWall.After(until.Truncate(-1)) {
|
||||
since = nowWall.Truncate(r.Config.Period)
|
||||
until = since.Add(r.Config.Period)
|
||||
}
|
||||
|
||||
r.UpdateWindow(since, until)
|
||||
|
||||
start := time.Now()
|
||||
|
|
|
|||
Loading…
Reference in New Issue