Start first aggregator period at startup time (#3050)

Fixes issue where metrics collected immediately after startup would not
be aggregated.
This commit is contained in:
Daniel Nelson
2017-07-24 18:25:05 -07:00
committed by GitHub
parent 6396e3409d
commit 6ae58430cd
3 changed files with 7 additions and 5 deletions

View File

@@ -114,6 +114,7 @@ func (r *RunningAggregator) reset() {
// for period ticks to tell it when to push and reset the aggregator.
func (r *RunningAggregator) Run(
acc telegraf.Accumulator,
now time.Time,
shutdown chan struct{},
) {
// The start of the period is truncated to the nearest second.
@@ -132,7 +133,6 @@ func (r *RunningAggregator) Run(
// 2nd interval: 00:10 - 00:20.5
// etc.
//
now := time.Now()
r.periodStart = now.Truncate(time.Second)
truncation := now.Sub(r.periodStart)
r.periodEnd = r.periodStart.Add(r.Config.Period)