fix(regression): Fixes problem with metrics not exposed by plugins. (#12016)
This commit is contained in:
parent
90d8f426b3
commit
ab293e853c
|
|
@ -280,20 +280,8 @@ func (a *Agent) runInputs(
|
|||
unit *inputUnit,
|
||||
) {
|
||||
var wg sync.WaitGroup
|
||||
tickers := make([]Ticker, len(unit.inputs))
|
||||
for _, input := range unit.inputs {
|
||||
a.runInput(ctx, startTime, unit, input, &wg)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
|
||||
log.Printf("D! [agent] Stopping service inputs")
|
||||
stopServiceInputs(unit.inputs)
|
||||
|
||||
close(unit.dst)
|
||||
log.Printf("D! [agent] Input channel closed")
|
||||
}
|
||||
|
||||
func (a *Agent) runInput(ctx context.Context, startTime time.Time, unit *inputUnit, input *models.RunningInput, wg *sync.WaitGroup) {
|
||||
// Overwrite agent interval if this plugin has its own.
|
||||
interval := time.Duration(a.Config.Agent.Interval)
|
||||
if input.Config.Interval != 0 {
|
||||
|
|
@ -324,7 +312,7 @@ func (a *Agent) runInput(ctx context.Context, startTime time.Time, unit *inputUn
|
|||
} else {
|
||||
ticker = NewUnalignedTicker(interval, jitter, offset)
|
||||
}
|
||||
defer ticker.Stop()
|
||||
tickers = append(tickers, ticker)
|
||||
|
||||
acc := NewAccumulator(input, unit.dst)
|
||||
acc.SetPrecision(getPrecision(precision, interval))
|
||||
|
|
@ -335,6 +323,15 @@ func (a *Agent) runInput(ctx context.Context, startTime time.Time, unit *inputUn
|
|||
a.gatherLoop(ctx, acc, input, ticker, interval)
|
||||
}(input)
|
||||
}
|
||||
defer stopTickers(tickers)
|
||||
wg.Wait()
|
||||
|
||||
log.Printf("D! [agent] Stopping service inputs")
|
||||
stopServiceInputs(unit.inputs)
|
||||
|
||||
close(unit.dst)
|
||||
log.Printf("D! [agent] Input channel closed")
|
||||
}
|
||||
|
||||
// testStartInputs is a variation of startInputs for use in --test and --once
|
||||
// mode. It differs by logging Start errors and returning only plugins
|
||||
|
|
@ -1110,3 +1107,9 @@ func panicRecover(input *models.RunningInput) {
|
|||
"https://github.com/influxdata/telegraf/issues/new/choose")
|
||||
}
|
||||
}
|
||||
|
||||
func stopTickers(tickers []Ticker) {
|
||||
for _, ticker := range tickers {
|
||||
ticker.Stop()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue