-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
filter_parser: Transition from single record to stream #4620
base: master
Are you sure you want to change the base?
filter_parser: Transition from single record to stream #4620
Conversation
@daipom i have raised this as a draft. This needs other changes like changing the tests around this, exception handling and etc. For now lets have discussion on the base logic and in meantime i will add them once we fix it |
Thanks! I will see this this weekend! |
904f7df
to
919e91b
Compare
@daipom thank you. The tests needs to be revamped for filter parser since the tests involve few instance variables. Do check it in freetime and let me know |
@daipom any opinion on this logic? Should we go ahead with this? |
@Athishpranav2003 Sorry for my late response. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Athishpranav2003 Sorry for my late response.
Basically, it looks good to me! Thanks for this fix!
We would like to address the tests while considering the following points.
- The behavior of
@emit_invalid_record_to_error
.- The reason why the old code raises errors would be that the following base class logic handled the errors.
fluentd/lib/fluent/plugin/filter.rb
Lines 86 to 91 in 919e91b
begin filtered_time, filtered_record = filter_with_time(tag, time, record) new_es.add(filtered_time, filtered_record) if filtered_time && filtered_record rescue => e router.emit_error_event(tag, time, record, e) end
- In the new code, we would need to handle it on the plugin side.
- The reason why the old code raises errors would be that the following base class logic handled the errors.
- Code readability.
- It appears that adding some inner methods would improve code readability.
- For example ...
def filter_stream(tag, es) new_es = Fluent::MultiEventStream.new es.each do |time, record| begin filter_one_record(tag, time, record) do |filtered_time, filtered_record| new_es.add(filtered_time, filtered_record) end rescue => e router.emit_error_event(tag, time, record, e) end end new_es end def filter_one_record(tag, time, record) ... yield result_time, result_record ... end
I guess we need to think a little better about handling error events... |
@daipom yah |
Thanks! This would be the right direction! |
919e91b
to
90c8501
Compare
@daipom you can check this now |
@daipom I guess the CI test fail is not related to this change |
Thanks!! I will see this!
Yes, They are not related. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Thanks!
Looks good to me for normal cases.
I'm concerned about some abnormal cases.
The behavior of some of rescue
cases appears to have changed.
I would like to have it checked.
I would be very happy if you could add some automated tests for the rescue
cases if possible, as there seems to be a lack of those tests.
fluentd/test/plugin/test_filter_parser.rb Lines 659 to 666 in 51b860b
could you please point which emit_event is this call part of |
After doing some verification fluentd/lib/fluent/plugin/filter.rb Lines 82 to 104 in 51b860b
The emit error event is in line 90/99. This implies that earlier we raise the exception in filter one record and capture in the filter stream. Now since we have implemented stream directly so the raise not needed
I used the following jugad way to find the function call |
Yes, we don't need |
In the current implementation: fluentd/lib/fluent/plugin/filter_parser.rb Lines 114 to 119 in 78a7972
In the new implementation: fluentd/lib/fluent/plugin/filter_parser.rb Lines 105 to 108 in 9ec5a95
This change is OK because |
@daipom
For now i have pushed the alternative code. Now the functionality looks visibly same as before. Could you please let me know which part is still ambigious and needs tests? |
9ec5a95
to
c9b61f2
Compare
I see. This test code specifies the content of expected arguments too strictly. diff --git a/test/plugin/test_filter_parser.rb b/test/plugin/test_filter_parser.rb
index ec36c836..4201cec8 100644
--- a/test/plugin/test_filter_parser.rb
+++ b/test/plugin/test_filter_parser.rb
@@ -650,7 +650,7 @@ class ParserFilterTest < Test::Unit::TestCase
def test_filter_key_not_exist
d = create_driver(CONFIG_NOT_IGNORE)
flexmock(d.instance.router).should_receive(:emit_error_event).
- with(String, Integer, Hash, ArgumentError.new("data does not exist")).once
+ with(String, Integer, Hash, ArgumentError).once
assert_nothing_raised {
d.run do
d.feed(@tag, Fluent::EventTime.now.to_i, {'foo' => 'bar'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I think it could be simpler, so I would suggest the following code change.
Got it @daipom |
Thanks! |
c9b61f2
to
cfb9f1d
Compare
@daipom i have addressed the comments. Additionally i felt there was a redundant rescue in the prev code so i have removed that as well. Is it fine now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!! The code change looks good to me!
I'd like to confirm the behavior a little more.
We would need more tests of anomaly scenarios.
I will add some tests later.
I made another PR to add some test cases for abnormal cases. Let's rebase after it is merged. I confirmed the test results on my local for this PR. fluentd/lib/fluent/plugin/filter_parser.rb Lines 114 to 119 in 51b860b
With this, I believe we should stop removing this The result of #4638 tests applied to this PR:
|
@daipom thanks for this help. I had difficulty in figuring out the edgecases. Thanks for doing it along with this to make it move ahead |
Signed-off-by: Athish Pranav D <[email protected]>
Signed-off-by: Athish Pranav D <[email protected]>
cfb9f1d
to
1ca7ea1
Compare
@daipom i have reverted the change with redundant rescue. Can you point out the change in the error messages if its still present in this pr? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashie @kenhys This solves the limitation of #4474, which is released on v1.17.0. I think it is possible to release this on v1.17. |
I'll second for v1.18. |
Which issue(s) this PR fixes:
Fixes #4100
What this PR does / why we need it:
Transition
filter_parser
from usingfilter_with_time
tofilter_stream
logicDocs Changes:
N/A
Release Note:
N/A