Class: Fluent::RemoveEmptyOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::RemoveEmptyOutput
- Defined in:
- lib/fluent/plugin/out_remove_empty.rb
Defined Under Namespace
Classes: PlaceholderExpander, RubyPlaceholderExpander
Constant Summary collapse
- BUILTIN_CONFIGURATIONS =
%W(type tag)
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #emit(tag, es, chain) ⇒ Object
-
#initialize ⇒ RemoveEmptyOutput
constructor
A new instance of RemoveEmptyOutput.
Constructor Details
#initialize ⇒ RemoveEmptyOutput
Returns a new instance of RemoveEmptyOutput.
8 9 10 |
# File 'lib/fluent/plugin/out_remove_empty.rb', line 8 def initialize super end |
Instance Method Details
#configure(conf) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fluent/plugin/out_remove_empty.rb', line 21 def configure(conf) super @map = {} conf.each_pair { |k, v| next if BUILTIN_CONFIGURATIONS.include?(k) conf.has_key?(k) # to suppress unread configuration warning @map[k] = v } if @tag.nil? raise Fluent::ConfigError, "out_remove_empty: `tag` must be specified" end @placeholder_expander = if @enable_ruby # require utilities which would be used in ruby placeholders require 'pathname' require 'uri' require 'cgi' RubyPlaceholderExpander.new(log) else PlaceholderExpander.new(log) end @hostname = Socket.gethostname end |
#emit(tag, es, chain) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/fluent/plugin/out_remove_empty.rb', line 49 def emit(tag, es, chain) tag_parts = tag.split('.') tag_prefix = tag_prefix(tag_parts) tag_suffix = tag_suffix(tag_parts) placeholders = { 'tag' => tag, 'tags' => tag_parts, 'tag_parts' => tag_parts, 'tag_prefix' => tag_prefix, 'tag_suffix' => tag_suffix, 'hostname' => @hostname, } last_record = nil es.each {|time, record| last_record = record # for debug log new_tag, new_record = reform(@tag, time, record, placeholders) Engine.emit(new_tag, time, new_record) } chain.next rescue => e log.warn "remove_empty: #{e.class} #{e.} #{e.backtrace.first}" log.debug "remove_empty: tag:#{@tag} map:#{@map} record:#{last_record} placeholders:#{placeholders}" end |