Automatically add missing new lines when combining exception stacks and make remove_tag_prefix mandatory#10
Automatically add missing new lines when combining exception stacks and make remove_tag_prefix mandatory#10thomasschickinger wants to merge 4 commits intomasterfrom
Conversation
|
I'm getting a following exception when using this branch |
|
Judging from the line where this error is reported (exception_detector.rb:229), I'd guess that $RS is not defined in your environment. Could you try replacing it with "\n" and check whether the error disappears? |
|
Yeah I was not sure, not a Rubyist here ;-) You're right, that fixes it. |
| def combined_message | ||
| combined = '' | ||
| @messages.each do |m| | ||
| combined << $RS if !combined.empty? && !combined.end_with?("\n") |
There was a problem hiding this comment.
Can we program defensively and use "\n" if $RS is nil?
There was a problem hiding this comment.
Done. Used a member variable for that in order to ensure that this is looked up only once.
There was a problem hiding this comment.
This is a static value that should never change. How about making it a class variable instead?
README.rdoc
Outdated
| {output plugin for fluentd}[http://docs.fluentd.org/articles/output-plugin-overview] | ||
| which scans a log stream text messages or JSON records for multi-line exception | ||
| stack traces: If a consecutive sequence of log messages forms an exception stack | ||
| which scans a log stream text messages or JSON records containing single |
There was a problem hiding this comment.
a log stream of text messages?
README.rdoc
Outdated
| are so similar (e.g. because they contain the timestamp of the log entry) that | ||
| this loss of information is irrelevant. | ||
|
|
||
| When combining exception lines, it is ensured that they enter with a line |
There was a problem hiding this comment.
Sorry, can't parse this. Did you mean s/enter/end/?
There was a problem hiding this comment.
Yes, thanks.
README.rdoc
Outdated
| this loss of information is irrelevant. | ||
|
|
||
| When combining exception lines, it is ensured that they enter with a line | ||
| separator. If they don't, a line separator is added to the original log message. |
There was a problem hiding this comment.
The second sentence is redundant (implied by "is ensured").
README.rdoc
Outdated
| @@ -53,7 +57,9 @@ The plugin supports the following parameters: | |||
| a record. A prefix has to be a complete tag part. | |||
There was a problem hiding this comment.
Let's change the heading to [remove_tag_prefix (required)] for consistency with other fluentd docs (e.g., in_tail) and make it the first parameter.
README.rdoc
Outdated
| tag foo.bar.baz is transformed to bar.baz and the input tag | ||
| 'foofoo.bar' is not modified. Default: empty string. | ||
| 'foofoo.bar' is not modified. | ||
| Removing a tag prefix is needed to avoid infinite |
There was a problem hiding this comment.
How about we put it in terms of what the user can/has to do, e.g.:
This must be non-empty to avoid infinite recursion in fluentd.
Speaking of which, do you want to check that this is non-empty and reject the config if it is? Removing the default simply ensures that this is specified by the user, not that it has a non-empty value.
There was a problem hiding this comment.
What about the second part of the suggestion (writing code to check that this is non-empty)?
There was a problem hiding this comment.
Check and test added.
| gem.required_ruby_version = Gem::Requirement.new('>= 2.0') | ||
|
|
||
| gem.files = Dir['**/*'].keep_if { |file| File.file?(file) } | ||
| gem.files = Dir['**/*'].keep_if{ |file| File.file?(file) && |
There was a problem hiding this comment.
Just curious: why did you have to remove the space before the opening brace?
There was a problem hiding this comment.
I didn't. Fixed.
|
|
||
| gem.files = Dir['**/*'].keep_if { |file| File.file?(file) } | ||
| gem.files = Dir['**/*'].keep_if{ |file| File.file?(file) && | ||
| !file.end_with?('gem') } |
There was a problem hiding this comment.
Nit: should this be !file.end_with?('.gem')?
| force_flush if @max_lines > 0 && @messages.length == @max_lines | ||
| end | ||
|
|
||
| def combined_message |
There was a problem hiding this comment.
I'm not happy with defining a method for this -- too much Ruby magic. You are essentially injecting newlines after trace lines that don't have them, right? Why not do it as a comprehension, e.g.:
combined_message = @messages.inject([]) {|r, e| r << e; r << $RS unless e.empty? || e.end_with?("\n"); r}.join
|
All comments addressed. PTAL. |
| def combined_message | ||
| combined = '' | ||
| @messages.each do |m| | ||
| combined << $RS if !combined.empty? && !combined.end_with?("\n") |
There was a problem hiding this comment.
This is a static value that should never change. How about making it a class variable instead?
README.rdoc
Outdated
| tag foo.bar.baz is transformed to bar.baz and the input tag | ||
| 'foofoo.bar' is not modified. Default: empty string. | ||
| 'foofoo.bar' is not modified. | ||
| Removing a tag prefix is needed to avoid infinite |
There was a problem hiding this comment.
What about the second part of the suggestion (writing code to check that this is non-empty)?
|
Hi Igor, comments addressed. PTAL. |
|
we've been running into the same problem this PR fixes recently. @igorpeshansky is there still anything left blocking from moving forward with this PR? |
|
Hi |
|
is this ever going to release??? |
|
Got the same issue this PR fixes. @igorpeshansky any update? |
|
any updates? |
|
I'm having the same issues with Java exceptions not having and ending new line char. |
|
Same here @igorpeshansky would be great if that could be merged |
|
@igorpeshansky what does it take to resolve this PR? |
This PR solves the following issues:
remove_tag_prefixis optional is a pitfall for users because re-emitting a log entry with the same tag causes an infinite recursion in fluentd.first_recordfield was only populated for JSON logs.The version number is bumped to 0.0.6