Sha256: 69624f1a1cba49f2ca25bf0b2d72f3a78ad72aae6250d9315dbce988638e1c95

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 Bytes

Contents

require 'fluent/mixin/config_placeholders'

module Fluent
  class RecordModifierOutput < Output
    Fluent::Plugin.register_output('record_modifier', self)

    config_param :tag, :string

    include SetTagKeyMixin
    include Fluent::Mixin::ConfigPlaceholders

    BUILTIN_CONFIGURATIONS = %W(type tag include_tag_key tag_key)

    def configure(conf)
      super

      @map = {}
      conf.each_pair { |k, v|
        unless BUILTIN_CONFIGURATIONS.include?(k)
          conf.has_key?(k)
          @map[k] = v
        end
      }
    end

    def emit(tag, es, chain)
      es.each { |time, record|
        Engine.emit(@tag, time, modify_record(record))
      }

      chain.next
    end

    private

    def modify_record(record)
      @map.each_pair { |k, v|
        record[k] = v
      }

      record
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-record-modifier-0.1.0 lib/fluent/plugin/out_record_modifier.rb