Skip to content

Conversation

@igorpeshansky
Copy link
Contributor

@igorpeshansky igorpeshansky commented Feb 6, 2019

Fixes #29.

Copy link

@StevenYCChou StevenYCChou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented on ruby part.

I don't have knowledge on java, so I cannot comment much whether the rules make sense, or whether regular expression is good.


def self.rule(from_state, pattern, to_state)
Struct::Rule.new(from_state, pattern, to_state)
def self.rule(from_states, pattern, to_state)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thoughts on the interface of this function:
can we always assume from_states is Array, and clients always need to pass Array in? 2 benefits:

  1. no special logic to convert single element to an array
  2. the client side code are consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of thinking of this as a function, think of this as a DSL for defining rules. We want to be able to define rules with a single transition, or with multiple transitions that share a regexp and the target state. In the former case we specify a single from state, and in the latter we specify an array of from states. Most rules will represent a single transition. The goal is to make the usage simpler, not the function implementation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Optional]

  1. still think from_states implies input of this parameter is a collection of items.
  2. still think always pass from_states parameter as array makes the client side code consistent - so user of this function (or DSL) don't need to reason two modes to use this rule function.

This comment falls under readability realm, so it's optional to change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point on the variable name ­— renamed to from_state_or_states.
The idea was to keep most of the existing rule statements unchanged.

Metrics/ClassLength:
Max: 1300

# Offense count: 1

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?

Copy link
Contributor Author

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...

Copy link
Contributor

@qingling128 qingling128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

RULES_BY_LANG.keys
end

JAVA_RULES = [
Copy link
Contributor

Choose a reason for hiding this comment

The 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:

    JAVA_RULES = [
      rule(:start_state,
           /(?:Exception|Error|Throwable|V8 errors stack trace)[:\r\n]/,
           :java),
      rule(:java, /^[\t ]*nested exception is:[\t ]*$/, :java),
      rule(:java, /^$/, :java),
      rule(:java, /^[\t ]+(?:eval )?at /, :java),
      rule(:java, /^[\t ]*(?:Caused by|Suppressed):/, :java),
      rule(:java, /^[\t ]*... \d+\ more/, :java)
    ].freeze

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would miss parsing the nested exception itself after the nested exception is: line. That's why I've introduced :java_start_exception. I suppose we could simply add a transition from :java to :java_start_exception on nested exception is:, but that would not make the rules much simpler. WDYT?

Copy link

@StevenYCChou StevenYCChou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

:java_after_exception),
rule([:java_after_exception, :java], /^[\t ]*... \d+\ more/, :java)
rule([:java_after_exception, :java],
/^[\t ]*... \d+ (?:more|common frames omitted)$/, :java)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why adding $ suddenly? and I cannot verify whether java would not add '\n', or other characters after those text. Do you have reference on source code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. The text ("more" or "common frames omitted") does appear at the end of the line, but log messages may also have linefeed/newline characters appended, so it's better to be careful. Fixed.

@igorpeshansky igorpeshansky merged commit 1e54284 into master Feb 6, 2019
@igorpeshansky igorpeshansky deleted the igorp-java-nested-exception branch February 6, 2019 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants