diff --git a/lib/fluent/agent.rb b/lib/fluent/agent.rb index 7e662704b1..33b081c3ef 100644 --- a/lib/fluent/agent.rb +++ b/lib/fluent/agent.rb @@ -159,7 +159,7 @@ def add_filter(type, pattern, conf) end # For handling invalid record - def emit_error_event(tag, time, record, error) + def emit_error_event(tag, time, record, error, plugin_id: nil) end def handle_emits_error(tag, es, error) diff --git a/lib/fluent/event_router.rb b/lib/fluent/event_router.rb index 9a133b5c6b..7961b2963c 100644 --- a/lib/fluent/event_router.rb +++ b/lib/fluent/event_router.rb @@ -123,7 +123,7 @@ def emit_stream(tag, es) end def emit_error_event(tag, time, record, error) - @emit_error_handler.emit_error_event(tag, time, record, error) + @emit_error_handler.emit_error_event(tag, time, record, error, plugin_id: @caller_plugin_id) end def match?(tag) diff --git a/lib/fluent/label.rb b/lib/fluent/label.rb index 674492efec..1899455fbb 100644 --- a/lib/fluent/label.rb +++ b/lib/fluent/label.rb @@ -35,8 +35,8 @@ def configure(conf) end end - def emit_error_event(tag, time, record, e) - @root_agent.emit_error_event(tag, time, record, e) + def emit_error_event(tag, time, record, e, plugin_id: nil) + @root_agent.emit_error_event(tag, time, record, e, plugin_id: plugin_id) end def handle_emits_error(tag, es, e) diff --git a/lib/fluent/root_agent.rb b/lib/fluent/root_agent.rb index d10f366044..383830dace 100644 --- a/lib/fluent/root_agent.rb +++ b/lib/fluent/root_agent.rb @@ -341,8 +341,9 @@ def find_label(label_name) end end - def emit_error_event(tag, time, record, error) + def emit_error_event(tag, time, record, error, plugin_id: nil) error_info = {error: error, location: (error.backtrace ? error.backtrace.first : nil), tag: tag, time: time} + error_info[:plugin_id] = plugin_id if plugin_id if @error_collector # A record is not included in the logs because <@ERROR> handles it. This warn is for the notification log.warn "send an error event to @ERROR:", error_info