Module: Fluent::SetTagKeyMixin

Includes:
RecordFilterMixin
Defined in:
lib/fluent/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.



172
173
174
# File 'lib/fluent/mixin.rb', line 172

def include_tag_key
  @include_tag_key
end

#tag_keyObject

Returns the value of attribute tag_key.



172
173
174
# File 'lib/fluent/mixin.rb', line 172

def tag_key
  @tag_key
end

Instance Method Details

#configure(conf) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/fluent/mixin.rb', line 174

def configure(conf)
  @include_tag_key = false

  super

  if s = conf['include_tag_key']
    include_tag_key = Config.bool_value(s)
    raise 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



189
190
191
192
193
# File 'lib/fluent/mixin.rb', line 189

def filter_record(tag, time, record)
  super

  record[@tag_key] = tag if @include_tag_key
end