From 6d873be3b7986a5050f448778638fed0fb2ac3e3 Mon Sep 17 00:00:00 2001 From: Ingvar Mattsson Date: Tue, 15 Jan 2019 08:05:20 +0000 Subject: [PATCH 1/4] Add parsing rules, and a test case, for "Go panicing in a http handler" --- lib/fluent/plugin/exception_detector.rb | 1 + test/plugin/test_exception_detector.rb | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/fluent/plugin/exception_detector.rb b/lib/fluent/plugin/exception_detector.rb index 96e41e7..88dea96 100644 --- a/lib/fluent/plugin/exception_detector.rb +++ b/lib/fluent/plugin/exception_detector.rb @@ -76,6 +76,7 @@ def self.supported GO_RULES = [ rule(:start_state, /\bpanic: /, :go_after_panic), + rule(:start_state, /http: panic /, :go_goroutine), rule(:go_after_panic, /^$/, :go_goroutine), rule(:go_after_panic, /^\[signal /, :go_after_signal), rule(:go_after_signal, /^$/, :go_goroutine), diff --git a/test/plugin/test_exception_detector.rb b/test/plugin/test_exception_detector.rb index e260c9e..915debb 100644 --- a/test/plugin/test_exception_detector.rb +++ b/test/plugin/test_exception_detector.rb @@ -214,6 +214,26 @@ class ExceptionDetectorTest < Test::Unit::TestCase server.go:20 +0x91 END + GO_HTTP = <:0 @@ -556,6 +576,7 @@ def test_go check_exception(GO_EXC, false) check_exception(GO_ON_GAE_EXC, false) check_exception(GO_SIGNAL_EXC, false) + check_exception(GO_HTTP, false) end def test_ruby From ee504cbc78b187ca46778d921e248234f76c843b Mon Sep 17 00:00:00 2001 From: Ingvar Mattsson Date: Sun, 20 Jan 2019 17:15:26 +0000 Subject: [PATCH 2/4] Disable rubocop class length check. --- lib/fluent/plugin/exception_detector.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fluent/plugin/exception_detector.rb b/lib/fluent/plugin/exception_detector.rb index 88dea96..b77195f 100644 --- a/lib/fluent/plugin/exception_detector.rb +++ b/lib/fluent/plugin/exception_detector.rb @@ -16,7 +16,7 @@ module Fluent Struct.new('Rule', :from_state, :pattern, :to_state) # Configuration of the state machine that detects exceptions. - module ExceptionDetectorConfig + module ExceptionDetectorConfig # rubocop:disable Metrics/ClassLength # Rule for a state transition: if pattern matches go to the given state. class RuleTarget attr_accessor :pattern, :to_state From fd738e12fc083b236b84491f026e7363ee4c37bd Mon Sep 17 00:00:00 2001 From: Ingvar Mattsson Date: Sun, 20 Jan 2019 17:22:46 +0000 Subject: [PATCH 3/4] Remove the classLength comment, increase the MethodLength value in .rubocop.yml. --- .rubocop.yml | 2 +- lib/fluent/plugin/exception_detector.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f88d786..8f07fdd 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -21,7 +21,7 @@ Metrics/CyclomaticComplexity: # Offense count: 5 # Configuration parameters: CountComments. Metrics/MethodLength: - Max: 150 + Max: 160 # Offense count: 3 Metrics/PerceivedComplexity: diff --git a/lib/fluent/plugin/exception_detector.rb b/lib/fluent/plugin/exception_detector.rb index b77195f..88dea96 100644 --- a/lib/fluent/plugin/exception_detector.rb +++ b/lib/fluent/plugin/exception_detector.rb @@ -16,7 +16,7 @@ module Fluent Struct.new('Rule', :from_state, :pattern, :to_state) # Configuration of the state machine that detects exceptions. - module ExceptionDetectorConfig # rubocop:disable Metrics/ClassLength + module ExceptionDetectorConfig # Rule for a state transition: if pattern matches go to the given state. class RuleTarget attr_accessor :pattern, :to_state From 0d5f537e6d14a7279981817e2b9e9315a64cbd69 Mon Sep 17 00:00:00 2001 From: Ingvar Mattsson Date: Sun, 20 Jan 2019 17:33:17 +0000 Subject: [PATCH 4/4] And now disable ModuleLength warning instead. --- lib/fluent/plugin/exception_detector.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fluent/plugin/exception_detector.rb b/lib/fluent/plugin/exception_detector.rb index 88dea96..687ef9b 100644 --- a/lib/fluent/plugin/exception_detector.rb +++ b/lib/fluent/plugin/exception_detector.rb @@ -16,7 +16,7 @@ module Fluent Struct.new('Rule', :from_state, :pattern, :to_state) # Configuration of the state machine that detects exceptions. - module ExceptionDetectorConfig + module ExceptionDetectorConfig # rubocop:disable Metrics/ModuleLength # Rule for a state transition: if pattern matches go to the given state. class RuleTarget attr_accessor :pattern, :to_state