GoogleCloudPlatform / fluent-plugin-detect-exceptions

A fluentd plugin that scans line-oriented log streams and combines exceptions stacks into a single log entry.
Apache License 2.0
192 stars 69 forks source link

Add support for Go recovered panics #98

Open kasparjarek opened 2 years ago

kasparjarek commented 2 years ago

When Go panic is recovered and thrown again it duplicates the first line of panic suffixed with [recovered]. The finite automaton is currently unable to recognise this panic output.

panic: foo [recovered]
    panic: foo [recovered]
    panic: foo [recovered]
    panic: foo

goroutine 1 [running]:
main.recoverAndPanic()
    /tmp/sandbox1820875720/prog.go:12 +0x34
panic({0x459120, 0x476600})
    /usr/local/go-faketime/src/runtime/panic.go:838 +0x207
main.recoverAndPanic()
    /tmp/sandbox1820875720/prog.go:12 +0x34
panic({0x459120, 0x476600})
    /usr/local/go-faketime/src/runtime/panic.go:838 +0x207
main.recoverAndPanic()
    /tmp/sandbox1820875720/prog.go:12 +0x34
panic({0x459120, 0x476600})
    /usr/local/go-faketime/src/runtime/panic.go:838 +0x207
main.main()
    /tmp/sandbox1820875720/prog.go:7 +0x5d

The output is produced by following code:

package main

func main() {
    defer recoverAndPanic()
    defer recoverAndPanic()
    defer recoverAndPanic()
    panic("foo")
}

func recoverAndPanic() {
    if r := recover(); r != nil {
        panic(r)
    }
}