diff --git a/lib/fluent/plugin_helper/event_emitter.rb b/lib/fluent/plugin_helper/event_emitter.rb index 103a8ef47b..256d837f77 100644 --- a/lib/fluent/plugin_helper/event_emitter.rb +++ b/lib/fluent/plugin_helper/event_emitter.rb @@ -42,6 +42,14 @@ def event_emitter_used_actually? @_event_emitter_used_actually end + def event_emitter_router(label_name) + if label_name + Engine.root_agent.find_label(label_name).event_router + else + Engine.root_agent.event_router + end + end + def initialize super @_event_emitter_used_actually = false @@ -50,13 +58,7 @@ def initialize 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 + @router = event_emitter_router(conf['@label']) end def after_shutdown