Skip to content

Add log failed expression #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/fluent/plugin/filter_record_modifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ def filter(tag, time, record)
tag_parts = @has_tag_parts ? tag.split('.') : nil

@map.each_pair { |k, v|
record[k] = v.expand(tag, time, record, tag_parts)
begin
record[k] = v.expand(tag, time, record, tag_parts)
rescue
$log.error("filter_record_modifier::filter - exception in expression: '#{v.getcode}'")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conf.elements.select { |element| element.name == 'record' }.each do |element|

config's record elements has original code so we don't need to store code in DynamicExpander.

raise
end
}

if @remove_keys
Expand Down Expand Up @@ -151,10 +156,16 @@ def check_config_placeholders(k, v)
end

class DynamicExpander
def getcode()
@code
end

def initialize(param_key, param_value, prepare_value)
if param_value.include?('${')
__str_eval_code__ = parse_parameter(param_value)

@code=__str_eval_code__

# Use class_eval with string instead of define_method for performance.
# It can't share instructions but this is 2x+ faster than define_method in filter case.
# Refer: http://tenderlovemaking.com/2013/03/03/dynamic_method_definitions.html
Expand Down