Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.1.10
- Added trace log to track event size expansion [#49](https://github.com/logstash-plugins/logstash-filter-split/pull/49)

## 3.1.9
- [DOC] Added introductory statement to clarify purpose of the plugin [#43](https://github.com/logstash-plugins/logstash-filter-split/pull/43)

Expand Down
16 changes: 14 additions & 2 deletions lib/logstash/filters/split.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,31 @@ def filter(event)

# set event_target to @field if not configured
event_target = @target.nil? ? @field : @target

split_bytes = 0
logger.trace? && logger.trace("Event being split into #{splits.size} events")
Copy link
Contributor

Choose a reason for hiding this comment

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

Just out of curiosity... Why are we guarding this with logger.trace? I get it for the other computations as they are somewhat expensive. If i understand correctly, the logging library will handle which messages to actually emit based on level. For example, a message sent with logger.trace('foo') would only ever show up in logs when the trace level logging is configured.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guard it to prevent paying the cost of string concatenation string + #{splits.size} + string that is not used in other info or debug level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guard it to prevent paying the cost of string concatenation string + #{splits.size} + string that is not used in other info or debug level.


splits.each do |value|
next if value.nil? || (value.is_a?(String) && value.empty?)
@logger.debug? && @logger.debug("Split event", :value => value, :field => @field)

event_split = event.clone
event_split.set(event_target, value)
filter_matched(event_split)

logger.trace? && split_bytes += event_split.to_json.size

# Push this new event onto the stack at the LogStash::FilterWorker
yield event_split
end


if logger.trace?
original_bytes = event.to_json.size
logger.trace("Estimated event size growth after split",
:original_bytes => original_bytes,
:split_bytes => split_bytes,
:growth_ratio => (split_bytes.to_f / original_bytes).round(2))
end

# Cancel this event, we'll use the newly generated ones above.
event.cancel
end
Expand Down
2 changes: 1 addition & 1 deletion logstash-filter-split.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|

s.name = 'logstash-filter-split'
s.version = '3.1.9'
s.version = '3.1.10'
s.licenses = ['Apache License (2.0)']
s.summary = "Splits multi-line messages into distinct events"
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
Expand Down