Module: Fluent::ExceptionDetectorConfig

Defined in:
lib/fluent/plugin/exception_detector.rb

Overview

Configuration of the state machine that detects exceptions.

Defined Under Namespace

Classes: RuleTarget

Constant Summary collapse

JAVA_RULES =
[
  rule([:start_state, :java_start_exception],
       /(?:Exception|Error|Throwable|V8 errors stack trace)[:\r\n]/,
       :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],
       # C# nested exception.
       /^[\t ]+--- End of inner exception stack trace ---$/,
       :java),

  rule([:java_after_exception, :java],
       # C# exception from async code.
       /^--- End of stack trace from previous (?x:
       )location where exception was thrown ---$/,
       :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 =
[
  rule(:start_state, /^Traceback \(most recent call last\):$/, :python),
  rule(:python, /^[\t ]+File /, :python_code),
  rule(:python_code, /[^\t ]/, :python),
  rule(:python, /^(?:[^\s.():]+\.)*[^\s.():]+:/, :start_state)
].freeze
PHP_RULES =
[
  rule(:start_state, /
    (?:PHP\ (?:Notice|Parse\ error|Fatal\ error|Warning):)|
    (?:exception\ '[^']+'\ with\ message\ ')/x, :php_stack_begin),
  rule(:php_stack_begin, /^Stack trace:/, :php_stack_frames),
  rule(:php_stack_frames, /^#\d/, :php_stack_frames),
  rule(:php_stack_frames, /^\s+thrown in /, :start_state)
].freeze
GO_RULES =
[
  rule(:start_state, /\bpanic: /, :go_after_panic),
  rule(:start_state, /http: panic serving/, :go_goroutine),
  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_goroutine, /^goroutine \d+ \[[^\]]+\]:$/, :go_frame_1),
  rule(:go_frame_1, /^(?:[^\s.:]+\.)*[^\s.():]+\(|^created by /,
       :go_frame_2),
  rule(:go_frame_2, /^\s/, :go_frame_1)
].freeze
RUBY_RULES =
[
  rule(:start_state, /Error \(.*\):$/, :ruby_before_rails_trace),
  rule(:ruby_before_rails_trace, /^  $/, :ruby),
  rule(:ruby_before_rails_trace, /^[\t ]+.*?\.rb:\d+:in `/, :ruby),
  rule(:ruby, /^[\t ]+.*?\.rb:\d+:in `/, :ruby)
].freeze
DART_RULES =
[
  rule(:start_state, /^Unhandled exception:$/, :dart_exc),
  rule(:dart_exc, /^Instance of/, :dart_stack),
  rule(:dart_exc, /^Exception/, :dart_stack),
  rule(:dart_exc, /^Bad state/, :dart_stack),
  rule(:dart_exc, /^IntegerDivisionByZeroException/, :dart_stack),
  rule(:dart_exc, /^Invalid argument/, :dart_stack),
  rule(:dart_exc, /^RangeError/, :dart_stack),
  rule(:dart_exc, /^Assertion failed/, :dart_stack),
  rule(:dart_exc, /^Cannot instantiate/, :dart_stack),
  rule(:dart_exc, /^Reading static variable/, :dart_stack),
  rule(:dart_exc, /^UnimplementedError/, :dart_stack),
  rule(:dart_exc, /^Unsupported operation/, :dart_stack),
  rule(:dart_exc, /^Concurrent modification/, :dart_stack),
  rule(:dart_exc, /^Out of Memory/, :dart_stack),
  rule(:dart_exc, /^Stack Overflow/, :dart_stack),
  rule(:dart_exc, /^'.+?':.+?$/, :dart_type_err_1),
  rule(:dart_type_err_1, /^#\d+\s+.+?\(.+?\)$/, :dart_stack),
  rule(:dart_type_err_1, /^.+?$/, :dart_type_err_2),
  rule(:dart_type_err_2, /^.*?\^.*?$/, :dart_type_err_3),
  rule(:dart_type_err_3, /^$/, :dart_type_err_4),
  rule(:dart_type_err_4, /^$/, :dart_stack),
  rule(:dart_exc, /^FormatException/, :dart_format_err_1),
  rule(:dart_format_err_1, /^#\d+\s+.+?\(.+?\)$/, :dart_stack),
  rule(:dart_format_err_1, /^./, :dart_format_err_2),
  rule(:dart_format_err_2, /^.*?\^/, :dart_format_err_3),
  rule(:dart_format_err_3, /^$/, :dart_stack),
  rule(:dart_exc, /^NoSuchMethodError:/, :dart_method_err_1),
  rule(:dart_method_err_1, /^Receiver:/, :dart_method_err_2),
  rule(:dart_method_err_2, /^Tried calling:/, :dart_method_err_3),
  rule(:dart_method_err_3, /^Found:/, :dart_stack),
  rule(:dart_method_err_3, /^#\d+\s+.+?\(.+?\)$/, :dart_stack),
  rule(:dart_stack, /^#\d+\s+.+?\(.+?\)$/, :dart_stack),
  rule(:dart_stack, /^<asynchronous suspension>$/, :dart_stack)
].freeze
ALL_RULES =
(
  JAVA_RULES + PYTHON_RULES + PHP_RULES + GO_RULES + RUBY_RULES + DART_RULES
).freeze
RULES_BY_LANG =
{
  java: JAVA_RULES,
  javascript: JAVA_RULES,
  js: JAVA_RULES,
  csharp: JAVA_RULES,
  py: PYTHON_RULES,
  python: PYTHON_RULES,
  php: PHP_RULES,
  go: GO_RULES,
  rb: RUBY_RULES,
  ruby: RUBY_RULES,
  dart: DART_RULES,
  all: ALL_RULES
}.freeze
DEFAULT_FIELDS =
%w(message log).freeze

Class Method Summary collapse

Class Method Details

.rule(from_state_or_states, pattern, to_state) ⇒ Object



44
45
46
47
48
# File 'lib/fluent/plugin/exception_detector.rb', line 44

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

.supportedObject



50
51
52
# File 'lib/fluent/plugin/exception_detector.rb', line 50

def self.supported
  RULES_BY_LANG.keys
end