-
Notifications
You must be signed in to change notification settings - Fork 69
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 a parameter for identifying log streams that shall be processed independently #5
Conversation
…th the message field.
@@ -44,7 +44,11 @@ The plugin supports the following parameters: | |||
|
|||
[message] Name of the field in the JSON record that contains the | |||
single-line log messages that shall be scanned for exceptions. | |||
Default: 'message'. | |||
If the setting is '', it will automatically be changed to 'message' |
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.
If this is set to '', the plugin will try 'message' and 'log', in that order.
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.
Done
Default: 1000. | ||
|
||
[max_bytes] Maximum number of bytes in a detected exception stack trace. | ||
If this maximum number is exceeded, the detected exception stack |
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.
"detected exception stack trace that has been detected so far" has one too many instances of "detected". I'd lose the first one.
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.
Done
Zero means no limit. | ||
Default: 0. | ||
|
||
[stream] Name of a field in the JSON record that contains the name of a |
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.
s/a field/the field/.
Default: 0. | ||
|
||
[stream] Name of a field in the JSON record that contains the name of a | ||
logical log stream within the 'real' log stream. |
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.
Nit: you use single quotes above to delimit field names. Here, 'real'
is just quoting a vague concept, so I'd use double quotes instead. Also below.
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.
Done
@@ -44,7 +44,11 @@ The plugin supports the following parameters: | |||
|
|||
[message] Name of the field in the JSON record that contains the | |||
single-line log messages that shall be scanned for exceptions. | |||
Default: 'message'. | |||
If the setting is '', it will automatically be changed to 'message' |
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.
This parameter is only applicable to structured (JSON) log streams.
Also below.
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.
Done
The exception detection is handled separately for each logical | ||
log stream, i.e., exceptions will be detected even if the messages | ||
for the logical log streams are interleaved in the 'real' log stream. | ||
Consequently, only records that belong to the same stream will be |
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.
the same logical stream
.
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.
Done
@@ -34,6 +34,8 @@ class DetectExceptionsOutput < Output | |||
config_param :max_lines, :integer, default: 1000 | |||
desc 'Maximum number of bytes to flush (0 means no limit). Default: 0.' | |||
config_param :max_bytes, :integer, default: 0 | |||
desc 'Separate log streams by this field (if set). Default: nil.' |
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.
nil
or ''
?
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.
Done
@@ -84,17 +86,19 @@ def emit(tag, es, chain) | |||
|
|||
def process_record(tag, time_sec, record) | |||
synchronize do | |||
unless @accumulators.key?(tag) | |||
accumulator_key = [tag] |
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.
I'd name it for its logical content, i.e., log_id
, rather its intended purpose (i.e., accumulator_key
).
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.
Done
log_entry | ||
end | ||
|
||
def feed_lines(driver, t, messages, stream: nil) |
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.
Since stream
as a named argument (rather than a positional with a default value), you should be able to keep *messages
(they shouldn't conflict) and save yourself a whole lot of square brackets.
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.
Good suggestion. Thanks.
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.
Approving with a couple of optional comments.
@@ -34,6 +34,8 @@ class DetectExceptionsOutput < Output | |||
config_param :max_lines, :integer, default: 1000 | |||
desc 'Maximum number of bytes to flush (0 means no limit). Default: 0.' | |||
config_param :max_bytes, :integer, default: 0 | |||
desc "Separate log streams by this field (if set). Default: ''." |
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.
[Optional] I'd suggest replacing "if set" with "unless empty" or something. Also, you could avoid the double quotes by saying "Default: empty". In fact, I'm not even sure you need to be explicit about the defaults for any of these in the descriptions -- the only reason it was specified for :languages
was because []
isn't immediately associated with "all". The rest are probably superfluous.
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.
Will go with not mentioning the default. This is also consistent with, e.g., remove_tag_prefix
.
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.
Might as well clean up the defaults for max_lines
and max_bytes
...
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.
max_lines has a default that is 'surprising'. I'll thus leave it in (and then for symmetry also the one for max_bytes).
@@ -84,17 +86,19 @@ def emit(tag, es, chain) | |||
|
|||
def process_record(tag, time_sec, record) | |||
synchronize do | |||
unless @accumulators.key?(tag) | |||
log_id = [tag] | |||
log_id.push(record.fetch(stream, '')) unless stream.empty? |
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.
[Optional] I think the config parameters manifest as instance fields, so it might pay to be explicit and use @stream
instead of just stream
(makes code searches much simpler too). Also for the other config parameters -- sorry I didn't pick up on this earlier. Feel free to defer this to a later cleanup.
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.
Cleanup done.
No description provided.