fix(agent): Catch panics in inputs goroutine (#14840)
This commit is contained in:
parent
c5ee403e9d
commit
6d523c96f3
|
|
@ -556,8 +556,6 @@ func (a *Agent) gatherLoop(
|
||||||
ticker Ticker,
|
ticker Ticker,
|
||||||
interval time.Duration,
|
interval time.Duration,
|
||||||
) {
|
) {
|
||||||
defer panicRecover(input)
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.Elapsed():
|
case <-ticker.Elapsed():
|
||||||
|
|
@ -581,6 +579,7 @@ func (a *Agent) gatherOnce(
|
||||||
) error {
|
) error {
|
||||||
done := make(chan error)
|
done := make(chan error)
|
||||||
go func() {
|
go func() {
|
||||||
|
defer panicRecover(input)
|
||||||
done <- input.Gather(acc)
|
done <- input.Gather(acc)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
@ -1200,7 +1199,7 @@ func panicRecover(input *models.RunningInput) {
|
||||||
runtime.Stack(trace, true)
|
runtime.Stack(trace, true)
|
||||||
log.Printf("E! FATAL: [%s] panicked: %s, Stack:\n%s",
|
log.Printf("E! FATAL: [%s] panicked: %s, Stack:\n%s",
|
||||||
input.LogName(), err, trace)
|
input.LogName(), err, trace)
|
||||||
log.Println("E! PLEASE REPORT THIS PANIC ON GITHUB with " +
|
log.Fatalln("E! PLEASE REPORT THIS PANIC ON GITHUB with " +
|
||||||
"stack trace, configuration, and OS information: " +
|
"stack trace, configuration, and OS information: " +
|
||||||
"https://github.com/influxdata/telegraf/issues/new/choose")
|
"https://github.com/influxdata/telegraf/issues/new/choose")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue