Class: Fluent::Filter

Inherits:
Object
  • Object
show all
Includes:
Configurable, PluginId, PluginLoggerMixin
Defined in:
lib/fluent/filter.rb

Constant Summary

Constants included from Configurable

Configurable::CONFIG_TYPE_REGISTRY

Instance Attribute Summary collapse

Attributes included from PluginLoggerMixin

#log

Instance Method Summary collapse

Methods included from PluginLoggerMixin

included

Methods included from PluginId

#plugin_id

Methods included from Configurable

#config, included, lookup_type, register_type

Constructor Details

#initializeFilter

Returns a new instance of Filter.



31
32
33
# File 'lib/fluent/filter.rb', line 31

def initialize
  super
end

Instance Attribute Details

#routerObject

Returns the value of attribute router.



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

def router
  @router
end

Instance Method Details

#configure(conf) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/fluent/filter.rb', line 35

def configure(conf)
  super

  if label_name = conf['@label']
    label = Engine.root_agent.find_label(label_name)
    @router = label.event_router
  elsif @router.nil?
    @router = Engine.root_agent.event_router
  end
end

#filter(tag, time, record) ⇒ Object

Raises:

  • (NotImplementedError)


52
53
54
# File 'lib/fluent/filter.rb', line 52

def filter(tag, time, record)
  raise NotImplementedError, "Implement this method in child class"
end

#filter_stream(tag, es) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fluent/filter.rb', line 56

def filter_stream(tag, es)
  new_es = MultiEventStream.new
  es.each { |time, record|
    begin
      filtered_record = filter(tag, time, record)
      new_es.add(time, filtered_record) if filtered_record
    rescue => e
      router.emit_error_event(tag, time, record, e)
    end
  }
  new_es
end

#shutdownObject



49
50
# File 'lib/fluent/filter.rb', line 49

def shutdown
end

#startObject



46
47
# File 'lib/fluent/filter.rb', line 46

def start
end