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 a parameter for identifying log streams that shall be processed independently #5

Merged
merged 5 commits into from
Dec 19, 2016

Conversation

thomasschickinger
Copy link
Contributor

No description provided.

@@ -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'
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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.
Copy link
Member

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.

Copy link
Contributor Author

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'
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

Choose a reason for hiding this comment

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

the same logical stream.

Copy link
Contributor Author

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.'
Copy link
Member

Choose a reason for hiding this comment

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

nil or ''?

Copy link
Contributor Author

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]
Copy link
Member

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).

Copy link
Contributor Author

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)
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion. Thanks.

Copy link
Member

@igorpeshansky igorpeshansky left a 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: ''."
Copy link
Member

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.

Copy link
Contributor Author

@thomasschickinger thomasschickinger Dec 19, 2016

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.

Copy link
Member

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...

Copy link
Contributor Author

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?
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cleanup done.

@thomasschickinger thomasschickinger merged commit e85f69d into master Dec 19, 2016
@thomasschickinger thomasschickinger deleted the separate_streams branch December 19, 2016 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants