-
Notifications
You must be signed in to change notification settings - Fork 69
Allow multiple start states for a rule. Support nested Java exceptions. #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
adbac8e
bb348c3
03a51a0
793032d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |
| # limitations under the License. | ||
| # | ||
| module Fluent | ||
| Struct.new('Rule', :from_state, :pattern, :to_state) | ||
| Struct.new('Rule', :from_states, :pattern, :to_state) | ||
|
|
||
| # Configuration of the state machine that detects exceptions. | ||
| module ExceptionDetectorConfig | ||
|
|
@@ -41,21 +41,28 @@ def state | |
| end | ||
| end | ||
|
|
||
| def self.rule(from_state, pattern, to_state) | ||
| Struct::Rule.new(from_state, pattern, to_state) | ||
| def self.rule(from_state_or_states, pattern, to_state) | ||
| from_state_or_states = [from_state_or_states] unless | ||
| from_state_or_states.is_a?(Array) | ||
| Struct::Rule.new(from_state_or_states, pattern, to_state) | ||
| end | ||
|
|
||
| def self.supported | ||
| RULES_BY_LANG.keys | ||
| end | ||
|
|
||
| JAVA_RULES = [ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Optional] Yesterday we chat about how we have more strict regex at client side than server side. Have we considered something looser? Like: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would miss parsing the nested exception itself after the |
||
| rule(:start_state, | ||
| rule([:start_state, :java_start_exception], | ||
| /(?:Exception|Error|Throwable|V8 errors stack trace)[:\r\n]/, | ||
| :java), | ||
| rule(:java, /^[\t ]+(?:eval )?at /, :java), | ||
| rule(:java, /^[\t ]*(?:Caused by|Suppressed):/, :java), | ||
| rule(:java, /^[\t ]*... \d+\ more/, :java) | ||
| :java_after_exception), | ||
| rule(:java_after_exception, /^[\t ]*nested exception is:[\t ]*/, | ||
| :java_start_exception), | ||
| rule(:java_after_exception, /^[\r\n]*$/, :java_after_exception), | ||
| rule([:java_after_exception, :java], /^[\t ]+(?:eval )?at /, :java), | ||
| rule([:java_after_exception, :java], /^[\t ]*(?:Caused by|Suppressed):/, | ||
| :java_after_exception), | ||
| rule([:java_after_exception, :java], | ||
| /^[\t ]*... \d+ (?:more|common frames omitted)/, :java) | ||
| ].freeze | ||
|
|
||
| PYTHON_RULES = [ | ||
|
|
@@ -76,13 +83,12 @@ def self.supported | |
|
|
||
| GO_RULES = [ | ||
| rule(:start_state, /\bpanic: /, :go_after_panic), | ||
| rule(:go_after_panic, /^$/, :go_goroutine), | ||
| rule([:go_after_panic, :go_after_signal, :go_frame_1], | ||
| /^$/, :go_goroutine), | ||
| rule(:go_after_panic, /^\[signal /, :go_after_signal), | ||
| rule(:go_after_signal, /^$/, :go_goroutine), | ||
| rule(:go_goroutine, /^goroutine \d+ \[[^\]]+\]:$/, :go_frame_1), | ||
| rule(:go_frame_1, /^(?:[^\s.:]+\.)*[^\s.():]+\(|^created by /, | ||
| :go_frame_2), | ||
| rule(:go_frame_1, /^$/, :go_goroutine), | ||
| rule(:go_frame_2, /^\s/, :go_frame_1) | ||
| ].freeze | ||
|
|
||
|
|
@@ -169,7 +175,9 @@ def initialize(*languages) | |
| rule_config.each do |r| | ||
| target = ExceptionDetectorConfig::RuleTarget.new(r[:pattern], | ||
| r[:to_state]) | ||
| @rules[r[:from_state]] << target | ||
| r[:from_states].each do |from_state| | ||
| @rules[from_state] << target | ||
| end | ||
| end | ||
| end | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the purpose of this configuration change on rubocop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The module in exception_detector.rb became too large...