Skip to content
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

Add filter_with_time to Fluent::Plugin::Filter #1140

Merged
merged 3 commits into from
Aug 10, 2016

Conversation

ganmacs
Copy link
Member

@ganmacs ganmacs commented Aug 4, 2016

This is for plugins that updates times when filtering.

ref: #1139

@ganmacs ganmacs force-pushed the add-new-method-to-filter branch 3 times, most recently from f253383 to 7cb5208 Compare August 5, 2016 03:47
end
end

def implemented_method_name
Copy link
Member

Choose a reason for hiding this comment

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

This process (detecting implemented methods) should be done as early as possible. Lazy call (the first time when events arrived) makes data loss if the filter was implemented in invalid way.
IMO it's best to do it in #initialize. Raising error in #initialize makes fluentd to stop at the time just launched.

Copy link
Member Author

@ganmacs ganmacs Aug 7, 2016

Choose a reason for hiding this comment

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

Because we can control a timing of raising an error and it is useful for test etc ,I added a code that check which method(filter or filter_with_time) implemented at #configure

Sorry, I misunderstood. I added add this method call to #initialize
https://github.com/fluent/fluentd/pull/1140/files#diff-3bdc55bd92825d185fcb6fc41334cef3R35

@ganmacs ganmacs force-pushed the add-new-method-to-filter branch 9 times, most recently from 6e933ce to ff34788 Compare August 7, 2016 13:16
when [:filter, :filter_with_time].all? { |e| implmented_methods.include?(e) }
raise "BUG: Filter plugins MUST be implemented either `filter` or `filter_with_time`"
when implmented_methods.include?(:filter)
:filter
Copy link
Member

Choose a reason for hiding this comment

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

This seems verbose. true / false is enough for me.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ganmacs ganmacs force-pushed the add-new-method-to-filter branch 3 times, most recently from 2b1bae7 to 3db34c4 Compare August 8, 2016 02:15
# Plugins that override `filter_stream` don't need check,
# because they may not call `filter` or `filter_with_time`
# for example fluentd/lib/fluent/plugin/filter_record_transformer.rb
return if implmented_methods.include?(:filter_stream)
Copy link
Member

Choose a reason for hiding this comment

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

Returning without any value looks not good manner for this method... What is set into @has_filter_with_time??
It's better to return nil or something else explicitly.
Code comment looks very good.

Copy link
Member Author

Choose a reason for hiding this comment

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

@tagomoris
Copy link
Member

@ganmacs Could you fix just one more point?

ganmacs added 2 commits August 8, 2016 14:14
this is for plugings that updates times when filtering
Avoid to call heavy method call in loop
@ganmacs ganmacs force-pushed the add-new-method-to-filter branch from 3db34c4 to ed21e9a Compare August 8, 2016 05:14
Plugins that override `filter_stream` don't need check,
because they may not call `filter` or `filter_with_time`
@ganmacs ganmacs force-pushed the add-new-method-to-filter branch from ed21e9a to 0353283 Compare August 8, 2016 05:32
@tagomoris tagomoris added feature request *Deprecated Label* Use enhancement label in general v0.14 labels Aug 10, 2016
@tagomoris tagomoris merged commit 1980ab1 into fluent:master Aug 10, 2016
@tagomoris
Copy link
Member

Great addition. Thank you!

@ganmacs ganmacs deleted the add-new-method-to-filter branch November 28, 2019 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request *Deprecated Label* Use enhancement label in general v0.14
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants