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

Fix to make oink skip lines with bad character encoding #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions lib/oink/active_record_instantiation_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ def print(output)
line = line.strip

# Skip this line since we're only interested in the Hodel 3000 compliant lines
next unless line =~ HODEL_LOG_FORMAT_REGEX
begin
next unless line =~ HODEL_LOG_FORMAT_REGEX
rescue => e
output.puts "\nSkipping malformed line" if @format == :verbose and e.message =~ /invalid byte sequence/
next
end

if line =~ /rails\[(\d+)\]/
pid = $1
Expand Down Expand Up @@ -65,4 +70,4 @@ def print(output)

end

end
end
12 changes: 9 additions & 3 deletions lib/oink/memory_usage_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ def print(output)
input.each_line do |line|
line = line.strip

# Skip this line since we're only interested in the Hodel 3000 compliant lines
next unless line =~ HODEL_LOG_FORMAT_REGEX
# Skip this line since we're only interested in the Hodel 3000 compliant lines
# Also skip lines that have the wrong character encoding
begin
next unless line =~ HODEL_LOG_FORMAT_REGEX
rescue => e
output.puts "\nSkipping malformed line" if @format == :verbose and e.message =~ /invalid byte sequence/
next
end

if line =~ /rails\[(\d+)\]/
pid = $1
Expand Down Expand Up @@ -69,4 +75,4 @@ def print(output)

end

end
end