Module: Fluent::Compat::SetTagKeyMixin

Includes:
RecordFilterMixin
Defined in:
lib/fluent/compat/set_tag_key_mixin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RecordFilterMixin

#format_stream

Instance Attribute Details

#include_tag_keyObject

Returns the value of attribute include_tag_key.



26
27
28
# File 'lib/fluent/compat/set_tag_key_mixin.rb', line 26

def include_tag_key
  @include_tag_key
end

#tag_keyObject

Returns the value of attribute tag_key.



26
27
28
# File 'lib/fluent/compat/set_tag_key_mixin.rb', line 26

def tag_key
  @tag_key
end

Instance Method Details

#configure(conf) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fluent/compat/set_tag_key_mixin.rb', line 28

def configure(conf)
  @include_tag_key = false

  super

  if s = conf['include_tag_key']
    include_tag_key = Fluent::Config.bool_value(s)
    raise Fluent::ConfigError, "Invalid boolean expression '#{s}' for include_tag_key parameter" if include_tag_key.nil?

    @include_tag_key = include_tag_key
  end

  @tag_key = conf['tag_key'] || 'tag' if @include_tag_key
end

#filter_record(tag, time, record) ⇒ Object



43
44
45
46
47
# File 'lib/fluent/compat/set_tag_key_mixin.rb', line 43

def filter_record(tag, time, record)
  super

  record[@tag_key] = tag if @include_tag_key
end