Skip to content

Commit

Permalink
Add support for Go recovered panics
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparjarek committed Sep 18, 2022
1 parent 17c846b commit 9d5388b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fluent/plugin/exception_detector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def self.supported
].freeze

GO_RULES = [
rule(:start_state, /\bpanic: /, :go_after_panic),
rule([:start_state, :go_after_panic], /\bpanic: /, :go_after_panic),
rule(:start_state, /http: panic serving/, :go_goroutine),
rule(:go_after_panic, /^$/, :go_goroutine),
rule([:go_after_panic, :go_after_signal, :go_frame_1],
Expand Down
25 changes: 25 additions & 0 deletions test/plugin/test_exception_detector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,30 @@ class ExceptionDetectorTest < Test::Unit::TestCase
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2851 +0x2f5
END

GO_RECOVERED = <<END.freeze
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
END

CSHARP_EXC = <<END.freeze
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2[System.String,System.Collections.Generic.Dictionary`2[System.Int32,System.Double]].get_Item (System.String key) [0x00000] in <filename unknown>:0
Expand Down Expand Up @@ -635,6 +659,7 @@ def test_go
check_exception(GO_ON_GAE_EXC, false)
check_exception(GO_SIGNAL_EXC, false)
check_exception(GO_HTTP, false)
check_exception(GO_RECOVERED, false)
end

def test_ruby
Expand Down

0 comments on commit 9d5388b

Please sign in to comment.