Class: Fluent::AddEmptyArrayOutput

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

Instance Method Summary collapse

Constructor Details

#initializeAddEmptyArrayOutput

Returns a new instance of AddEmptyArrayOutput.



8
9
10
# File 'lib/fluent/plugin/out_add_empty_array.rb', line 8

def initialize
  super
end

Instance Method Details

#add_empty_array(record) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/fluent/plugin/out_add_empty_array.rb', line 51

def add_empty_array(record)
  @array_type_key.each do |key|
    record[key] = [] unless record.has_key?(key)
  end
  return record
rescue => e
  log.warn("out_add_empty_array: error_class:#{e.class} error_message:#{e.message} tag:#{tag} record:#{record} bactrace:#{e.backtrace.first}")
end

#configure(conf) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fluent/plugin/out_add_empty_array.rb', line 17

def configure(conf)
  super

  if @array_type_key
    @array_type_key = @array_type_key.split(@delimiter)
  end

  unless @array_type_key
    raise ConfigError, "'array_type_key' parameter is required on 'fluent-plugin-add_empty_array'"
  end
end

#emit(tag, es, chain) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fluent/plugin/out_add_empty_array.rb', line 37

def emit(tag, es, chain)
  es.each {|time, record|
    t = tag.dup
    new_record = add_empty_array(record)

    t = @tag_prefix + t unless @tag_prefix.nil?

    Engine.emit(t, time, new_record)
  }
  chain.next
rescue => e
  log.warn("out_add_empty_array: error_class:#{e.class} error_message:#{e.message} tag:#{tag} es:#{es} record:#{record} bactrace:#{e.backtrace.first}")
end

#shutdownObject



33
34
35
# File 'lib/fluent/plugin/out_add_empty_array.rb', line 33

def shutdown
  super
end

#startObject



29
30
31
# File 'lib/fluent/plugin/out_add_empty_array.rb', line 29

def start
  super
end