Skip to content

Commit

Permalink
moved HODEL_LOG_FORMAT_REGEX to Oink::Base class and skip non Hodel 3…
Browse files Browse the repository at this point in the history
…000 compliant lines from both the MemoryUsageReporter and ActiveRecordInstantiationReporter classes
  • Loading branch information
Michel Barbosa committed Jan 7, 2010
1 parent 0a6edeb commit 86c59e0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/oink/active_record_instantiation_reporter.rb
Expand Up @@ -16,6 +16,9 @@ def print(output)
@inputs.each do |input|
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

if line =~ /rails\[(\d+)\]/
pid = $1
Expand All @@ -40,7 +43,7 @@ def print(output)
if @pids[pid][:ar_count] > @threshold
@bad_actions[@pids[pid][:action]] ||= 0
@bad_actions[@pids[pid][:action]] = @bad_actions[@pids[pid][:action]] + 1
date = /^(\w+ \d{2} \d{2}:\d{2}:\d{2})/.match(line).captures[0]
date = HODEL_LOG_FORMAT_REGEX.match(line).captures[0]
@bad_requests.push(OinkedARRequest.new(@pids[pid][:action], date, @pids[pid][:buffer], @pids[pid][:ar_count]))
if @format == :verbose
@pids[pid][:buffer].each { |b| output.puts b }
Expand Down
1 change: 1 addition & 0 deletions lib/oink/base.rb
Expand Up @@ -5,6 +5,7 @@ class Base
VERSION = '0.1.0'
FORMATS = %w[verbose short-summary summary]
FORMAT_ALIASES = { "v" => "verbose", "ss" => "short-summary", "s" => "summary" }
HODEL_LOG_FORMAT_REGEX = /^(\w+ \d{2} \d{2}:\d{2}:\d{2})/

def initialize(input, threshold, options = {})
@inputs = Array(input)
Expand Down
6 changes: 2 additions & 4 deletions lib/oink/memory_usage_reporter.rb
Expand Up @@ -6,8 +6,6 @@
module Oink

class MemoryUsageReporter < Base
HODEL_LOG_FORMAT_REGEX = /^(\w+ \d{2} \d{2}:\d{2}:\d{2})/

def print(output)
output.puts "---- MEMORY THRESHOLD ----"
output.puts "THRESHOLD: #{@threshold/1024} MB\n"
Expand All @@ -16,10 +14,10 @@ def print(output)

@inputs.each do |input|
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

line = line.strip

if line =~ /rails\[(\d+)\]/
pid = $1
Expand Down

0 comments on commit 86c59e0

Please sign in to comment.