Skip to content

Commit 9d5388b

Browse files
committed
Add support for Go recovered panics
1 parent 17c846b commit 9d5388b

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/fluent/plugin/exception_detector.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def self.supported
9494
].freeze
9595

9696
GO_RULES = [
97-
rule(:start_state, /\bpanic: /, :go_after_panic),
97+
rule([:start_state, :go_after_panic], /\bpanic: /, :go_after_panic),
9898
rule(:start_state, /http: panic serving/, :go_goroutine),
9999
rule(:go_after_panic, /^$/, :go_goroutine),
100100
rule([:go_after_panic, :go_after_signal, :go_frame_1],

test/plugin/test_exception_detector.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,30 @@ class ExceptionDetectorTest < Test::Unit::TestCase
262262
created by net/http.(*Server).Serve
263263
/usr/local/go/src/net/http/server.go:2851 +0x2f5
264264
END
265+
266+
GO_RECOVERED = <<END.freeze
267+
panic: foo [recovered]
268+
panic: foo [recovered]
269+
panic: foo [recovered]
270+
panic: foo
271+
272+
goroutine 1 [running]:
273+
main.recoverAndPanic()
274+
/tmp/sandbox1820875720/prog.go:12 +0x34
275+
panic({0x459120, 0x476600})
276+
/usr/local/go-faketime/src/runtime/panic.go:838 +0x207
277+
main.recoverAndPanic()
278+
/tmp/sandbox1820875720/prog.go:12 +0x34
279+
panic({0x459120, 0x476600})
280+
/usr/local/go-faketime/src/runtime/panic.go:838 +0x207
281+
main.recoverAndPanic()
282+
/tmp/sandbox1820875720/prog.go:12 +0x34
283+
panic({0x459120, 0x476600})
284+
/usr/local/go-faketime/src/runtime/panic.go:838 +0x207
285+
main.main()
286+
/tmp/sandbox1820875720/prog.go:7 +0x5d
287+
END
288+
265289
CSHARP_EXC = <<END.freeze
266290
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
267291
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
@@ -635,6 +659,7 @@ def test_go
635659
check_exception(GO_ON_GAE_EXC, false)
636660
check_exception(GO_SIGNAL_EXC, false)
637661
check_exception(GO_HTTP, false)
662+
check_exception(GO_RECOVERED, false)
638663
end
639664

640665
def test_ruby

0 commit comments

Comments
 (0)