fix(agent): Catch panics in inputs goroutine (#14840)

This commit is contained in:
Mingyang Zheng 2024-02-26 11:59:16 -08:00 committed by GitHub
parent c5ee403e9d
commit 6d523c96f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 3 deletions

View File

@ -556,8 +556,6 @@ func (a *Agent) gatherLoop(
ticker Ticker,
interval time.Duration,
) {
defer panicRecover(input)
for {
select {
case <-ticker.Elapsed():
@ -581,6 +579,7 @@ func (a *Agent) gatherOnce(
) error {
done := make(chan error)
go func() {
defer panicRecover(input)
done <- input.Gather(acc)
}()
@ -1200,7 +1199,7 @@ func panicRecover(input *models.RunningInput) {
runtime.Stack(trace, true)
log.Printf("E! FATAL: [%s] panicked: %s, Stack:\n%s",
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: " +
"https://github.com/influxdata/telegraf/issues/new/choose")
}