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



69
70
71
72
# File 'lib/fluent/plugin/out_detect_exceptions.rb', line 69

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



82
83
84
85
86
87
# File 'lib/fluent/plugin/out_detect_exceptions.rb', line 82

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

#multi_workers_ready?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/fluent/plugin/out_detect_exceptions.rb', line 55

def multi_workers_ready?
  true
end

#shutdownObject



74
75
76
77
78
79
80
# File 'lib/fluent/plugin/out_detect_exceptions.rb', line 74

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



59
60
61
62
63
64
65
66
67
# File 'lib/fluent/plugin/out_detect_exceptions.rb', line 59

def start
  super

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