Class: Fluent::DetectExceptionsOutput

Inherits:
Output
  • Object
show all
Defined in:
lib/fluent/plugin/out_detect_exceptions.rb

Overview

This output plugin consumes a log stream of JSON objects which contain single-line log messages. If a consecutive sequence of log messages form an exception stack trace, they forwarded as a single, combined JSON object. Otherwise, the input log data is forwarded as is.

Instance Method Summary collapse

Instance Method Details

#before_shutdownObject



65
66
67
68
# File 'lib/fluent/plugin/out_detect_exceptions.rb', line 65

def before_shutdown
  flush_buffers
  super if defined?(super)
end

#configure(conf) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fluent/plugin/out_detect_exceptions.rb', line 42

def configure(conf)
  super

  if multiline_flush_interval
    @check_flush_interval = [multiline_flush_interval * 0.1, 1].max
  end

  @languages = languages.map(&:to_sym)

  # Maps log stream tags to a corresponding TraceAccumulator.
  @accumulators = {}
end

#emit(tag, es, chain) ⇒ Object



78
79
80
81
82
83
# File 'lib/fluent/plugin/out_detect_exceptions.rb', line 78

def emit(tag, es, chain)
  es.each do |time_sec, record|
    process_record(tag, time_sec, record)
  end
  chain.next
end

#shutdownObject



70
71
72
73
74
75
76
# File 'lib/fluent/plugin/out_detect_exceptions.rb', line 70

def shutdown
  # Before shutdown is not available in older fluentd versions.
  # Hence, we make sure that we flush the buffers here as well.
  flush_buffers
  @thread.join if @multiline_flush_interval
  super
end

#startObject



55
56
57
58
59
60
61
62
63
# File 'lib/fluent/plugin/out_detect_exceptions.rb', line 55

def start
  super

  if multiline_flush_interval
    @flush_buffer_mutex = Mutex.new
    @stop_check = false
    @thread = Thread.new(&method(:check_flush_loop))
  end
end