Skip to content

Commit 2d4f379

Browse files
committed
log: add caller plugin-id about emitting error events
It would be helpful if we could know what plugin emitted the error event. #4567 We need to care about the compatibility. This signature change would not break compatibility. However, I'm concerned that `caller_plugin_id` has a race condition, although I don't confirm it. It looks to me that the id can be another plugin-id running concurrently... It is not the issue with this fix, it is the issue of the existing implementation. Signed-off-by: Daijiro Fukuda <[email protected]>
1 parent 51b860b commit 2d4f379

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

lib/fluent/agent.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def add_filter(type, pattern, conf)
159159
end
160160

161161
# For handling invalid record
162-
def emit_error_event(tag, time, record, error)
162+
def emit_error_event(tag, time, record, error, plugin_id: nil)
163163
end
164164

165165
def handle_emits_error(tag, es, error)

lib/fluent/event_router.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def emit_stream(tag, es)
123123
end
124124

125125
def emit_error_event(tag, time, record, error)
126-
@emit_error_handler.emit_error_event(tag, time, record, error)
126+
@emit_error_handler.emit_error_event(tag, time, record, error, plugin_id: @caller_plugin_id)
127127
end
128128

129129
def match?(tag)

lib/fluent/label.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def configure(conf)
3535
end
3636
end
3737

38-
def emit_error_event(tag, time, record, e)
39-
@root_agent.emit_error_event(tag, time, record, e)
38+
def emit_error_event(tag, time, record, e, plugin_id: nil)
39+
@root_agent.emit_error_event(tag, time, record, e, plugin_id: plugin_id)
4040
end
4141

4242
def handle_emits_error(tag, es, e)

lib/fluent/root_agent.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,9 @@ def find_label(label_name)
341341
end
342342
end
343343

344-
def emit_error_event(tag, time, record, error)
344+
def emit_error_event(tag, time, record, error, plugin_id: nil)
345345
error_info = {error: error, location: (error.backtrace ? error.backtrace.first : nil), tag: tag, time: time}
346+
error_info[:plugin_id] = plugin_id if plugin_id
346347
if @error_collector
347348
# A record is not included in the logs because <@ERROR> handles it. This warn is for the notification
348349
log.warn "send an error event to @ERROR:", error_info

0 commit comments

Comments
 (0)