Skip to content

Commit 38c60c5

Browse files
vatineqingling128
authored andcommitted
Add parsing rules, and a test case, for "Go panicing in a http handler". (#49)
1 parent 69d95d2 commit 38c60c5

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Metrics/CyclomaticComplexity:
2626
# Offense count: 5
2727
# Configuration parameters: CountComments.
2828
Metrics/MethodLength:
29-
Max: 150
29+
Max: 160
3030

3131
# Offense count: 3
3232
Metrics/PerceivedComplexity:

lib/fluent/plugin/exception_detector.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def self.supported
8383

8484
GO_RULES = [
8585
rule(:start_state, /\bpanic: /, :go_after_panic),
86+
rule(:start_state, /http: panic serving/, :go_goroutine),
87+
rule(:go_after_panic, /^$/, :go_goroutine),
8688
rule([:go_after_panic, :go_after_signal, :go_frame_1],
8789
/^$/, :go_goroutine),
8890
rule(:go_after_panic, /^\[signal /, :go_after_signal),

test/plugin/test_exception_detector.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,26 @@ class ExceptionDetectorTest < Test::Unit::TestCase
242242
server.go:20 +0x91
243243
END
244244

245+
GO_HTTP = <<END.freeze
246+
2019/01/15 07:48:05 http: panic serving [::1]:54143: test panic
247+
goroutine 24 [running]:
248+
net/http.(*conn).serve.func1(0xc00007eaa0)
249+
/usr/local/go/src/net/http/server.go:1746 +0xd0
250+
panic(0x12472a0, 0x12ece10)
251+
/usr/local/go/src/runtime/panic.go:513 +0x1b9
252+
main.doPanic(0x12f0ea0, 0xc00010e1c0, 0xc000104400)
253+
/Users/ingvar/src/go/src/httppanic.go:8 +0x39
254+
net/http.HandlerFunc.ServeHTTP(0x12be2e8, 0x12f0ea0, 0xc00010e1c0, 0xc000104400)
255+
/usr/local/go/src/net/http/server.go:1964 +0x44
256+
net/http.(*ServeMux).ServeHTTP(0x14a17a0, 0x12f0ea0, 0xc00010e1c0, 0xc000104400)
257+
/usr/local/go/src/net/http/server.go:2361 +0x127
258+
net/http.serverHandler.ServeHTTP(0xc000085040, 0x12f0ea0, 0xc00010e1c0, 0xc000104400)
259+
/usr/local/go/src/net/http/server.go:2741 +0xab
260+
net/http.(*conn).serve(0xc00007eaa0, 0x12f10a0, 0xc00008a780)
261+
/usr/local/go/src/net/http/server.go:1847 +0x646
262+
created by net/http.(*Server).Serve
263+
/usr/local/go/src/net/http/server.go:2851 +0x2f5
264+
END
245265
CSHARP_EXC = <<END.freeze
246266
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
247267
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
@@ -585,6 +605,7 @@ def test_go
585605
check_exception(GO_EXC, false)
586606
check_exception(GO_ON_GAE_EXC, false)
587607
check_exception(GO_SIGNAL_EXC, false)
608+
check_exception(GO_HTTP, false)
588609
end
589610

590611
def test_ruby

0 commit comments

Comments
 (0)