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_ERROR_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
RUBY_SEGFAULT_RULES =
[
  rule(:start_state,
       /:\d+:\s\[BUG\] Segmentation fault/, :ruby_segfault),
  rule(:ruby_segfault, /^ruby\n*/, :ruby_segfault),
  rule(:ruby_segfault, /^\n*$/, :ruby_segfault),
  rule(:ruby_segfault,
       /^-- Control frame information --/, :ruby_control_frames),
  rule(:ruby_control_frames, /^c:/, :ruby_control_frames),
  rule(:ruby_control_frames, /^\n*$/, :ruby_segfault),
  rule([:ruby_segfault, :ruby_control_frames],
       /^-- Ruby level backtrace information --/,
       :ruby_level_backtrace_frames),
  rule(:ruby_level_backtrace_frames, /:\d+:in /,
       :ruby_level_backtrace_frames),
  rule(:ruby_level_backtrace_frames, /^\n*$/, :ruby_segfault),
  rule([:ruby_segfault, :ruby_level_backtrace_frames],
       /^-- Machine register context --/, :ruby_machine_registers),
  rule(:ruby_machine_registers, /: /, :ruby_machine_registers),
  rule(:ruby_machine_registers, /^\n*$/, :ruby_segfault),
  rule([:ruby_segfault, :ruby_machine_registers],
       /^-- C level backtrace information --/,
       :ruby_c_level_backtrace_frames),
  rule(:ruby_c_level_backtrace_frames, /\[.*\]/,
       :ruby_c_level_backtrace_frames),
  rule(:ruby_c_level_backtrace_frames, / .*:\d+$/,
       :ruby_c_level_backtrace_frames),
  rule(:ruby_c_level_backtrace_frames, /^\n*$/, :ruby_segfault),
  rule([:ruby_segfault, :ruby_c_level_backtrace_frames],
       /^-- Other runtime information/, :ruby_other_runtime_info),
  rule(:ruby_other_runtime_info, /^\n*$/, :ruby_other_runtime_info),
  rule(:ruby_other_runtime_info, /^* Loaded script:/, :ruby_loaded_script),
  rule(:ruby_loaded_script, /^\n*$/, :ruby_loaded_features),
  rule([:ruby_loaded_features, :ruby_loaded_script],
       /^* Loaded features:/, :ruby_loaded_features),
  rule(:ruby_loaded_features, /^\n*$/, :ruby_loaded_features_frames),
  rule([:ruby_loaded_features_frames, :ruby_loaded_features],
       /\d/, :ruby_loaded_features_frames),
  rule(:ruby_loaded_features_frames,
       /^\n*$/, :ruby_process_memory_map),
  rule([:ruby_process_memory_map, :ruby_loaded_features_frames],
       /^* Process memory map:/, :ruby_process_memory_map),
  rule(:ruby_process_memory_map,
       /^\n*$/, :ruby_process_memory_map_frames),
  rule([:ruby_process_memory_map_frames, :ruby_process_memory_map],
       /\-/, :ruby_process_memory_map_frames),
  rule(:ruby_process_memory_map_frames, /^\n*$/, :start_state)
].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
RUBY_RULES =
(
  RUBY_ERROR_RULES + RUBY_SEGFAULT_RULES
).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