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, /(?:Exception|Error|Throwable|V8 errors stack trace)[:\r\n]/, :java),
  rule(:start_state, /^ERROR /, :java_stack_begin),
  rule(:java_stack_begin, /(?: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|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, /panic: /, :go_before_goroutine),
  rule(:go_before_goroutine, /^$/, :go_goroutine),
  rule(:go_goroutine, /^goroutine \d+ \[[^\]]+\]:$/, :go_frame_1),
  rule(:go_frame_1, /(?:[^\s.():]+\.)*[^\s.():]\(/, :go_frame_2),
  rule(:go_frame_1, /^$/, :go_before_goroutine),
  rule(:go_frame_2, /^\s/, :go_frame_1)
].freeze
RUBY_RULES =
[
  rule(:start_state, /Error \(.*\):$/, :ruby),
  rule(:ruby, /^[\t ]+.*?\.rb:\d+:in `/, :ruby)
].freeze
ALL_RULES =
(
JAVA_RULES + PYTHON_RULES + PHP_RULES + GO_RULES + RUBY_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,
  all: ALL_RULES
}.freeze
DEFAULT_FIELDS =
%w(message log).freeze

Class Method Summary collapse

Class Method Details

.rule(from_state, pattern, to_state) ⇒ Object



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

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

.supportedObject



48
49
50
# File 'lib/fluent/plugin/exception_detector.rb', line 48

def self.supported
  RULES_BY_LANG.keys
end