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



67
68
69
70
# File 'lib/fluent/plugin/out_detect_exceptions.rb', line 67

def before_shutdown
  flush_buffers
  super if defined?(super)
end

#configure(conf) ⇒ Object



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

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



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

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

#shutdownObject



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

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



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

def start
  super

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