request-log-analyzer 1.12.5 → 1.12.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -76,7 +76,8 @@ rescue CommandLine::Error => e
76
76
  puts "Input options:"
77
77
  puts " --after <date> Only consider requests from <date> or later."
78
78
  puts " --before <date> Only consider requests before <date>."
79
- puts " --format <format>, -f: Log file format. amazon_s3, apache, merb, mysql, rack or rails."
79
+ puts " --format <format>, -f: Log file format: amazon_s3, apache, delayed_job, haproxy, merb, mysql,"
80
+ puts " postgresql, rack, rails, rails3, w3c."
80
81
  puts " --reject <field> <value> Only consider requests where <field> does not match <value>."
81
82
  puts " --select <field> <value> Only consider requests where <field> matches <value>."
82
83
  puts
File without changes
@@ -1,5 +1,5 @@
1
1
  require 'date'
2
- require 'ordered_hash'
2
+ require 'other/ordered_hash'
3
3
 
4
4
  # RequestLogAnalyzer is the base namespace in which all functionality of RequestLogAnalyzer is implemented.
5
5
  # This module itselfs contains some functions to help with class and source file loading. The actual
@@ -11,7 +11,7 @@ module RequestLogAnalyzer
11
11
 
12
12
  # The current version of request-log-analyzer.
13
13
  # Do not change the value by hand; it will be updated automatically by the gem release script.
14
- VERSION = "1.12.4"
14
+ VERSION = "1.12.6"
15
15
 
16
16
  # Convert a string/symbol in camelcase ({RequestLogAnalyzer::Controller}) to underscores
17
17
  # (<tt>request_log_analyzer/controller</tt>). This function can be used to load the file (using
@@ -7,6 +7,7 @@ module RequestLogAnalyzer::FileFormat
7
7
  autoload :Rack, 'request_log_analyzer/file_format/rack'
8
8
  autoload :Merb, 'request_log_analyzer/file_format/merb'
9
9
  autoload :Mysql, 'request_log_analyzer/file_format/mysql'
10
+ autoload :Nginx, 'request_log_analyzer/file_format/nginx'
10
11
  autoload :Postgresql, 'request_log_analyzer/file_format/postgresql'
11
12
  autoload :DelayedJob, 'request_log_analyzer/file_format/delayed_job'
12
13
  autoload :DelayedJob2, 'request_log_analyzer/file_format/delayed_job2'
@@ -20,6 +20,7 @@ module RequestLogAnalyzer::FileFormat
20
20
  LOG_FORMAT_DEFAULTS = {
21
21
  :common => '%h %l %u %t "%r" %>s %b',
22
22
  :combined => '%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i"',
23
+ :nginx => '%a %t %h %u "%r" %>s %b',
23
24
  :rack => '%h %l %u %t "%r" %>s %b %T',
24
25
  :referer => '%{Referer}i -> %U',
25
26
  :agent => '%{User-agent}i'
@@ -0,0 +1,9 @@
1
+ module RequestLogAnalyzer::FileFormat
2
+
3
+ class Nginx < Apache
4
+
5
+ def self.create(*args)
6
+ super(:nginx, *args)
7
+ end
8
+ end
9
+ end
@@ -61,13 +61,21 @@ module RequestLogAnalyzer::FileFormat
61
61
  line.capture(:line).as(:integer)
62
62
  line.capture(:file)
63
63
  end
64
-
64
+
65
+ # Rendered queries/index.html.erb (0.6ms)
66
+ line_definition :rendered do |line|
67
+ line.compound = [:partial_duration]
68
+ line.teaser = / Rendered /
69
+ line.regexp = / Rendered ([a-zA-Z0-9_\-\/.]+(?:\/[a-zA-Z0-9_\-.]+)+)(?:\ within\ .*?)? \((\d+(?:\.\d+)?)ms\)/
70
+ line.capture(:rendered_file)
71
+ line.capture(:partial_duration).as(:duration, :unit => :msec)
72
+ end
73
+
65
74
  # # Not parsed at the moment:
66
75
  # SQL (0.2ms) SET SQL_AUTO_IS_NULL=0
67
76
  # Query Load (0.4ms) SELECT `queries`.* FROM `queries`
68
77
  # Rendered collection (0.0ms)
69
- # Rendered queries/index.html.erb (0.6ms)
70
-
78
+
71
79
  REQUEST_CATEGORIZER = lambda { |request| "#{request[:controller]}##{request[:action]}.#{request[:format]}" }
72
80
 
73
81
  report do |analyze|
@@ -80,6 +88,7 @@ module RequestLogAnalyzer::FileFormat
80
88
  analyze.frequency :status, :title => 'HTTP statuses returned'
81
89
 
82
90
  analyze.duration :duration, :category => REQUEST_CATEGORIZER, :title => "Request duration", :line_type => :completed
91
+ analyze.duration :partial_duration, :category => :rendered_file, :title => 'Partials rendering time', :line_type => :rendered
83
92
  analyze.duration :view, :category => REQUEST_CATEGORIZER, :title => "View rendering time", :line_type => :completed
84
93
  analyze.duration :db, :category => REQUEST_CATEGORIZER, :title => "Database time", :line_type => :completed
85
94
 
@@ -44,7 +44,7 @@ module RequestLogAnalyzer
44
44
  end
45
45
 
46
46
  attr_reader :name
47
- attr_accessor :teaser, :regexp, :captures
47
+ attr_accessor :teaser, :regexp, :captures, :compound
48
48
  attr_accessor :header, :footer
49
49
 
50
50
  alias_method :header?, :header
@@ -56,6 +56,7 @@ module RequestLogAnalyzer
56
56
  @name = name
57
57
  @captures = []
58
58
  @teaser = nil
59
+ @compound = []
59
60
  definition.each { |key, value| self.send("#{key.to_s}=".to_sym, value) }
60
61
  end
61
62
 
@@ -116,6 +116,7 @@ module RequestLogAnalyzer
116
116
  value_hash[:line_type] = parsed_line[:line_definition].name
117
117
  value_hash[:lineno] = parsed_line[:lineno]
118
118
  value_hash[:source] = parsed_line[:source]
119
+ value_hash[:compound] = parsed_line[:line_definition].compound
119
120
  add_line_hash(value_hash)
120
121
  end
121
122
 
@@ -124,7 +125,19 @@ module RequestLogAnalyzer
124
125
  # The line should be provides as a hash of the fields parsed from the line.
125
126
  def add_line_hash(value_hash)
126
127
  @lines << value_hash
127
- @attributes = value_hash.merge(@attributes)
128
+ if value_hash[:compound]
129
+ value_hash.each do |key, value|
130
+ if value_hash[:compound].include?(key)
131
+ @attributes[key] = [] if @attributes[key].nil?
132
+ @attributes[key] = [@attributes[key]] unless @attributes[key].is_a?(Array)
133
+ @attributes[key] << value
134
+ else
135
+ @attributes[key] = value unless key == :compound || @attributes[key]
136
+ end
137
+ end
138
+ else
139
+ @attributes = value_hash.merge(@attributes)
140
+ end
128
141
  end
129
142
 
130
143
  # Adds another line to the request. This method switches automatically between
@@ -118,6 +118,11 @@ module RequestLogAnalyzer::Source
118
118
  # <tt>options</tt>:: A Hash of options that will be pased to parse_io.
119
119
  def parse_file(file, options = {}, &block)
120
120
 
121
+ if File.directory?(file)
122
+ parse_files(Dir["#{ file }/*"], options, &block)
123
+ return
124
+ end
125
+
121
126
  @current_source = File.expand_path(file)
122
127
  @source_changes_handler.call(:started, @current_source) if @source_changes_handler
123
128
 
@@ -49,11 +49,10 @@ module RequestLogAnalyzer::Tracker
49
49
  found_categories.each_with_index do |cat, index|
50
50
  update_statistics(cat, found_values[index]) if cat && found_values[index].kind_of?(Numeric)
51
51
  end
52
-
53
52
  else
54
53
  category = @categorizer.call(request)
55
54
  value = @valueizer.call(request)
56
- update_statistics(category, value) if value.kind_of?(Numeric) && category
55
+ update_statistics(category, value) if (value.kind_of?(Numeric) || value.kind_of?(Array)) && category
57
56
  end
58
57
  end
59
58
 
@@ -227,6 +226,8 @@ module RequestLogAnalyzer::Tracker
227
226
  # <tt>category</tt>:: The category for which to update the running statistics calculations
228
227
  # <tt>number</tt>:: The numeric value to update the calculations with.
229
228
  def update_statistics(category, number)
229
+ return number.map {|n| update_statistics(category, n)} if number.is_a?(Array)
230
+
230
231
  @categories[category] ||= { :hits => 0, :sum => 0, :mean => 0.0, :sum_of_squares => 0.0, :min => number, :max => number,
231
232
  :buckets => Array.new(@number_of_buckets, 0) }
232
233
 
@@ -2,8 +2,8 @@ Gem::Specification.new do |s|
2
2
  s.name = "request-log-analyzer"
3
3
 
4
4
  # Do not set the version and date field manually, this is done by the release script
5
- s.version = "1.12.5"
6
- s.date = "2012-09-20"
5
+ s.version = "1.12.6"
6
+ s.date = "2012-12-10"
7
7
 
8
8
  s.rubyforge_project = 'r-l-a'
9
9
 
@@ -45,6 +45,6 @@ Gem::Specification.new do |s|
45
45
 
46
46
  # The files and test_files directives are set automatically by the release script.
47
47
  # Do not change them by hand, but make sure to add the files to the git repository.
48
- s.files = %w(.gitignore .infinity_test .travis.yml DESIGN.rdoc Gemfile LICENSE README.rdoc Rakefile bin/request-log-analyzer lib/cli/command_line_arguments.rb lib/cli/database_console.rb lib/cli/database_console_init.rb lib/cli/progressbar.rb lib/cli/tools.rb lib/ordered_hash.rb lib/request_log_analyzer.rb lib/request_log_analyzer/aggregator.rb lib/request_log_analyzer/aggregator/database_inserter.rb lib/request_log_analyzer/aggregator/echo.rb lib/request_log_analyzer/aggregator/summarizer.rb lib/request_log_analyzer/controller.rb lib/request_log_analyzer/database.rb lib/request_log_analyzer/database/base.rb lib/request_log_analyzer/database/connection.rb lib/request_log_analyzer/database/request.rb lib/request_log_analyzer/database/source.rb lib/request_log_analyzer/database/warning.rb lib/request_log_analyzer/file_format.rb lib/request_log_analyzer/file_format/amazon_s3.rb lib/request_log_analyzer/file_format/apache.rb lib/request_log_analyzer/file_format/delayed_job.rb lib/request_log_analyzer/file_format/delayed_job2.rb lib/request_log_analyzer/file_format/delayed_job21.rb lib/request_log_analyzer/file_format/haproxy.rb lib/request_log_analyzer/file_format/merb.rb lib/request_log_analyzer/file_format/mysql.rb lib/request_log_analyzer/file_format/oink.rb lib/request_log_analyzer/file_format/postgresql.rb lib/request_log_analyzer/file_format/rack.rb lib/request_log_analyzer/file_format/rails.rb lib/request_log_analyzer/file_format/rails3.rb lib/request_log_analyzer/file_format/rails_development.rb lib/request_log_analyzer/file_format/w3c.rb lib/request_log_analyzer/filter.rb lib/request_log_analyzer/filter/anonymize.rb lib/request_log_analyzer/filter/field.rb lib/request_log_analyzer/filter/timespan.rb lib/request_log_analyzer/line_definition.rb lib/request_log_analyzer/log_processor.rb lib/request_log_analyzer/mailer.rb lib/request_log_analyzer/output.rb lib/request_log_analyzer/output/fixed_width.rb lib/request_log_analyzer/output/html.rb lib/request_log_analyzer/request.rb lib/request_log_analyzer/source.rb lib/request_log_analyzer/source/log_parser.rb lib/request_log_analyzer/tracker.rb lib/request_log_analyzer/tracker/duration.rb lib/request_log_analyzer/tracker/frequency.rb lib/request_log_analyzer/tracker/hourly_spread.rb lib/request_log_analyzer/tracker/numeric_value.rb lib/request_log_analyzer/tracker/timespan.rb lib/request_log_analyzer/tracker/traffic.rb request-log-analyzer.gemspec spec/database.yml spec/fixtures/apache_combined.log spec/fixtures/apache_common.log spec/fixtures/decompression.log spec/fixtures/decompression.log.bz2 spec/fixtures/decompression.log.gz spec/fixtures/decompression.log.zip spec/fixtures/decompression.tar.gz spec/fixtures/decompression.tgz spec/fixtures/header_and_footer.log spec/fixtures/merb.log spec/fixtures/merb_prefixed.log spec/fixtures/multiple_files_1.log spec/fixtures/multiple_files_2.log spec/fixtures/mysql_slow_query.log spec/fixtures/oink_22.log spec/fixtures/oink_22_failure.log spec/fixtures/postgresql.log spec/fixtures/rails.db spec/fixtures/rails_1x.log spec/fixtures/rails_22.log spec/fixtures/rails_22_cached.log spec/fixtures/rails_unordered.log spec/fixtures/sinatra.log spec/fixtures/syslog_1x.log spec/fixtures/test_file_format.log spec/fixtures/test_language_combined.log spec/fixtures/test_order.log spec/integration/command_line_usage_spec.rb spec/integration/mailer_spec.rb spec/integration/munin_plugins_rails_spec.rb spec/integration/scout_spec.rb spec/lib/helpers.rb spec/lib/macros.rb spec/lib/matchers.rb spec/lib/mocks.rb spec/lib/testing_format.rb spec/spec_helper.rb spec/unit/aggregator/database_inserter_spec.rb spec/unit/aggregator/summarizer_spec.rb spec/unit/controller/controller_spec.rb spec/unit/controller/log_processor_spec.rb spec/unit/database/base_class_spec.rb spec/unit/database/connection_spec.rb spec/unit/database/database_spec.rb spec/unit/file_format/amazon_s3_format_spec.rb spec/unit/file_format/apache_format_spec.rb spec/unit/file_format/common_regular_expressions_spec.rb spec/unit/file_format/delayed_job21_format_spec.rb spec/unit/file_format/delayed_job2_format_spec.rb spec/unit/file_format/delayed_job_format_spec.rb spec/unit/file_format/file_format_api_spec.rb spec/unit/file_format/format_autodetection_spec.rb spec/unit/file_format/haproxy_format_spec.rb spec/unit/file_format/line_definition_spec.rb spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/mysql_format_spec.rb spec/unit/file_format/oink_format_spec.rb spec/unit/file_format/postgresql_format_spec.rb spec/unit/file_format/rack_format_spec.rb spec/unit/file_format/rails3_format_spec.rb spec/unit/file_format/rails_format_spec.rb spec/unit/file_format/w3c_format_spec.rb spec/unit/filter/anonymize_filter_spec.rb spec/unit/filter/field_filter_spec.rb spec/unit/filter/filter_spec.rb spec/unit/filter/timespan_filter_spec.rb spec/unit/mailer_spec.rb spec/unit/request_spec.rb spec/unit/source/log_parser_spec.rb spec/unit/tracker/duration_tracker_spec.rb spec/unit/tracker/frequency_tracker_spec.rb spec/unit/tracker/hourly_spread_spec.rb spec/unit/tracker/numeric_value_tracker_spec.rb spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/tracker_api_spec.rb spec/unit/tracker/traffic_tracker_spec.rb tasks/github-gem.rake tasks/request_log_analyzer.rake)
48
+ s.files = %w(.gitignore .infinity_test .travis.yml DESIGN.rdoc Gemfile LICENSE README.rdoc Rakefile bin/request-log-analyzer lib/cli/command_line_arguments.rb lib/cli/database_console.rb lib/cli/database_console_init.rb lib/cli/progressbar.rb lib/cli/tools.rb lib/other/ordered_hash.rb lib/request_log_analyzer.rb lib/request_log_analyzer/aggregator.rb lib/request_log_analyzer/aggregator/database_inserter.rb lib/request_log_analyzer/aggregator/echo.rb lib/request_log_analyzer/aggregator/summarizer.rb lib/request_log_analyzer/controller.rb lib/request_log_analyzer/database.rb lib/request_log_analyzer/database/base.rb lib/request_log_analyzer/database/connection.rb lib/request_log_analyzer/database/request.rb lib/request_log_analyzer/database/source.rb lib/request_log_analyzer/database/warning.rb lib/request_log_analyzer/file_format.rb lib/request_log_analyzer/file_format/amazon_s3.rb lib/request_log_analyzer/file_format/apache.rb lib/request_log_analyzer/file_format/delayed_job.rb lib/request_log_analyzer/file_format/delayed_job2.rb lib/request_log_analyzer/file_format/delayed_job21.rb lib/request_log_analyzer/file_format/haproxy.rb lib/request_log_analyzer/file_format/merb.rb lib/request_log_analyzer/file_format/mysql.rb lib/request_log_analyzer/file_format/nginx.rb lib/request_log_analyzer/file_format/oink.rb lib/request_log_analyzer/file_format/postgresql.rb lib/request_log_analyzer/file_format/rack.rb lib/request_log_analyzer/file_format/rails.rb lib/request_log_analyzer/file_format/rails3.rb lib/request_log_analyzer/file_format/rails_development.rb lib/request_log_analyzer/file_format/w3c.rb lib/request_log_analyzer/filter.rb lib/request_log_analyzer/filter/anonymize.rb lib/request_log_analyzer/filter/field.rb lib/request_log_analyzer/filter/timespan.rb lib/request_log_analyzer/line_definition.rb lib/request_log_analyzer/log_processor.rb lib/request_log_analyzer/mailer.rb lib/request_log_analyzer/output.rb lib/request_log_analyzer/output/fixed_width.rb lib/request_log_analyzer/output/html.rb lib/request_log_analyzer/request.rb lib/request_log_analyzer/source.rb lib/request_log_analyzer/source/log_parser.rb lib/request_log_analyzer/tracker.rb lib/request_log_analyzer/tracker/duration.rb lib/request_log_analyzer/tracker/frequency.rb lib/request_log_analyzer/tracker/hourly_spread.rb lib/request_log_analyzer/tracker/numeric_value.rb lib/request_log_analyzer/tracker/timespan.rb lib/request_log_analyzer/tracker/traffic.rb request-log-analyzer.gemspec spec/database.yml spec/fixtures/apache_combined.log spec/fixtures/apache_common.log spec/fixtures/decompression.log spec/fixtures/decompression.log.bz2 spec/fixtures/decompression.log.gz spec/fixtures/decompression.log.zip spec/fixtures/decompression.tar.gz spec/fixtures/decompression.tgz spec/fixtures/header_and_footer.log spec/fixtures/merb.log spec/fixtures/merb_prefixed.log spec/fixtures/multiple_files_1.log spec/fixtures/multiple_files_2.log spec/fixtures/mysql_slow_query.log spec/fixtures/oink_22.log spec/fixtures/oink_22_failure.log spec/fixtures/postgresql.log spec/fixtures/rails.db spec/fixtures/rails_1x.log spec/fixtures/rails_22.log spec/fixtures/rails_22_cached.log spec/fixtures/rails_3_partials.log spec/fixtures/rails_unordered.log spec/fixtures/s3_logs/2012-10-05-16-18-11-F9AAC5D1A55AEBAD spec/fixtures/s3_logs/2012-10-05-16-26-06-15314AF7F0651839 spec/fixtures/sinatra.log spec/fixtures/syslog_1x.log spec/fixtures/test_file_format.log spec/fixtures/test_language_combined.log spec/fixtures/test_order.log spec/integration/command_line_usage_spec.rb spec/integration/mailer_spec.rb spec/integration/munin_plugins_rails_spec.rb spec/integration/scout_spec.rb spec/lib/helpers.rb spec/lib/macros.rb spec/lib/matchers.rb spec/lib/mocks.rb spec/lib/testing_format.rb spec/spec_helper.rb spec/unit/aggregator/database_inserter_spec.rb spec/unit/aggregator/summarizer_spec.rb spec/unit/controller/controller_spec.rb spec/unit/controller/log_processor_spec.rb spec/unit/database/base_class_spec.rb spec/unit/database/connection_spec.rb spec/unit/database/database_spec.rb spec/unit/file_format/amazon_s3_format_spec.rb spec/unit/file_format/apache_format_spec.rb spec/unit/file_format/common_regular_expressions_spec.rb spec/unit/file_format/delayed_job21_format_spec.rb spec/unit/file_format/delayed_job2_format_spec.rb spec/unit/file_format/delayed_job_format_spec.rb spec/unit/file_format/file_format_api_spec.rb spec/unit/file_format/format_autodetection_spec.rb spec/unit/file_format/haproxy_format_spec.rb spec/unit/file_format/line_definition_spec.rb spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/mysql_format_spec.rb spec/unit/file_format/oink_format_spec.rb spec/unit/file_format/postgresql_format_spec.rb spec/unit/file_format/rack_format_spec.rb spec/unit/file_format/rails3_format_spec.rb spec/unit/file_format/rails_format_spec.rb spec/unit/file_format/w3c_format_spec.rb spec/unit/filter/anonymize_filter_spec.rb spec/unit/filter/field_filter_spec.rb spec/unit/filter/filter_spec.rb spec/unit/filter/timespan_filter_spec.rb spec/unit/mailer_spec.rb spec/unit/request_spec.rb spec/unit/source/log_parser_spec.rb spec/unit/tracker/duration_tracker_spec.rb spec/unit/tracker/frequency_tracker_spec.rb spec/unit/tracker/hourly_spread_spec.rb spec/unit/tracker/numeric_value_tracker_spec.rb spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/tracker_api_spec.rb spec/unit/tracker/traffic_tracker_spec.rb tasks/github-gem.rake tasks/request_log_analyzer.rake)
49
49
  s.test_files = %w(spec/integration/command_line_usage_spec.rb spec/integration/mailer_spec.rb spec/integration/munin_plugins_rails_spec.rb spec/integration/scout_spec.rb spec/unit/aggregator/database_inserter_spec.rb spec/unit/aggregator/summarizer_spec.rb spec/unit/controller/controller_spec.rb spec/unit/controller/log_processor_spec.rb spec/unit/database/base_class_spec.rb spec/unit/database/connection_spec.rb spec/unit/database/database_spec.rb spec/unit/file_format/amazon_s3_format_spec.rb spec/unit/file_format/apache_format_spec.rb spec/unit/file_format/common_regular_expressions_spec.rb spec/unit/file_format/delayed_job21_format_spec.rb spec/unit/file_format/delayed_job2_format_spec.rb spec/unit/file_format/delayed_job_format_spec.rb spec/unit/file_format/file_format_api_spec.rb spec/unit/file_format/format_autodetection_spec.rb spec/unit/file_format/haproxy_format_spec.rb spec/unit/file_format/line_definition_spec.rb spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/mysql_format_spec.rb spec/unit/file_format/oink_format_spec.rb spec/unit/file_format/postgresql_format_spec.rb spec/unit/file_format/rack_format_spec.rb spec/unit/file_format/rails3_format_spec.rb spec/unit/file_format/rails_format_spec.rb spec/unit/file_format/w3c_format_spec.rb spec/unit/filter/anonymize_filter_spec.rb spec/unit/filter/field_filter_spec.rb spec/unit/filter/filter_spec.rb spec/unit/filter/timespan_filter_spec.rb spec/unit/mailer_spec.rb spec/unit/request_spec.rb spec/unit/source/log_parser_spec.rb spec/unit/tracker/duration_tracker_spec.rb spec/unit/tracker/frequency_tracker_spec.rb spec/unit/tracker/hourly_spread_spec.rb spec/unit/tracker/numeric_value_tracker_spec.rb spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/tracker_api_spec.rb spec/unit/tracker/traffic_tracker_spec.rb)
50
50
  end
@@ -0,0 +1,13 @@
1
+ Started GET "/foobartest" for 127.0.0.1 at 2012-11-21 15:21:13 +0100
2
+ Processing by HomeController#foobartest as */*
3
+ Rendered home/foobartest_partial.html.slim (10.0ms)
4
+ Rendered home/foobartest_partial.html.slim (10.0ms)
5
+ Rendered home/foobartest_partial.html.slim (10.0ms)
6
+ Completed 200 OK in 58ms (Views: 44.6ms | ActiveRecord: 0.0ms)
7
+
8
+
9
+ Started GET "/foobartest" for 127.0.0.1 at 2012-11-21 15:21:31 +0100
10
+ Processing by HomeController#foobartest as */*
11
+ Rendered home/foobartest_partial.html.slim (100.0ms)
12
+ Rendered home/foobartest_partial.html.slim (0.0ms)
13
+ Completed 200 OK in 2ms (Views: 0.6ms | ActiveRecord: 0.0ms)
@@ -0,0 +1,5 @@
1
+ 300a66dd319290e36b67767f862a7f39072caa70ba33b8d01c4b79ddd8e6d7ef lamestuff.com [05/Oct/2012:15:24:46 +0000] 174.44.160.70 - CE74FF983317B326 REST.GET.OBJECT public/portfolio/22/thumbnail.jpg "GET /lamestuff.com/public/portfolio/22/thumbnail.jpg HTTP/1.1" 200 - 9515 9515 42 41 "http://spike.grobste.in/portfolio" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14" -
2
+ 300a66dd319290e36b67767f862a7f39072caa70ba33b8d01c4b79ddd8e6d7ef lamestuff.com [05/Oct/2012:15:25:20 +0000] 174.44.160.70 - D484E1F8E6DE0AAB REST.GET.OBJECT public/projects/46/resume.png "GET /lamestuff.com/public/projects/46/resume.png HTTP/1.1" 200 - 510856 510856 85 74 "http://spike.grobste.in/portfolio/show?name=lamestuff.com-%282007%29" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14" -
3
+ 300a66dd319290e36b67767f862a7f39072caa70ba33b8d01c4b79ddd8e6d7ef lamestuff.com [05/Oct/2012:15:25:25 +0000] 174.44.160.70 - E5C48446A01539FC REST.GET.OBJECT public/projects/3/gameboy.jpg "GET /lamestuff.com/public/projects/3/gameboy.jpg HTTP/1.1" 200 - 37458 37458 57 55 "http://spike.grobste.in/project/classic-console-art" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14" -
4
+ 300a66dd319290e36b67767f862a7f39072caa70ba33b8d01c4b79ddd8e6d7ef lamestuff.com [05/Oct/2012:15:25:27 +0000] 174.44.160.70 - CD6CC6713DE2254A REST.GET.OBJECT public/projects/115/xmas-card-2006-d.jpg "GET /lamestuff.com/public/projects/115/xmas-card-2006-d.jpg HTTP/1.1" 200 - 89892 89892 58 55 "http://spike.grobste.in/portfolio/show?name=xmas-2006" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14" -
5
+ 300a66dd319290e36b67767f862a7f39072caa70ba33b8d01c4b79ddd8e6d7ef lamestuff.com [05/Oct/2012:15:25:31 +0000] 174.44.160.70 - B8B9CBDE2EFE51F3 REST.GET.OBJECT public/projects/34/Tim_Horton-Window-Coffee-ba.jpg "GET /lamestuff.com/public/projects/34/Tim_Horton-Window-Coffee-ba.jpg HTTP/1.1" 200 - 27376 27376 41 40 "http://spike.grobste.in/project/tim-horton's-at-the-nyse" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14" -
@@ -0,0 +1,3 @@
1
+ 300a66dd319290e36b67767f862a7f39072caa70ba33b8d01c4b79ddd8e6d7ef lamestuff.com [05/Oct/2012:15:24:46 +0000] 174.44.160.70 - FC6B8CCFF3510D92 REST.GET.OBJECT public/portfolio/29/thumbnail.jpg "GET /lamestuff.com/public/portfolio/29/thumbnail.jpg HTTP/1.1" 200 - 6240 6240 40 39 "http://spike.grobste.in/portfolio" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14" -
2
+ 300a66dd319290e36b67767f862a7f39072caa70ba33b8d01c4b79ddd8e6d7ef lamestuff.com [05/Oct/2012:15:25:27 +0000] 174.44.160.70 - 6908D7E8249F8AB0 REST.GET.OBJECT public/projects/114/xmas-card-2006-c.jpg "GET /lamestuff.com/public/projects/114/xmas-card-2006-c.jpg HTTP/1.1" 200 - 99874 99874 51 47 "http://spike.grobste.in/portfolio/show?name=xmas-2006" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14" -
3
+ 300a66dd319290e36b67767f862a7f39072caa70ba33b8d01c4b79ddd8e6d7ef lamestuff.com [05/Oct/2012:15:25:30 +0000] 174.44.160.70 - 41804BB9A626C674 REST.GET.OBJECT public/projects/28/Tim_Horton_Counter__3x12_.jpg "GET /lamestuff.com/public/projects/28/Tim_Horton_Counter__3x12_.jpg HTTP/1.1" 200 - 22256 22256 93 91 "http://spike.grobste.in/project/tim-horton's-at-the-nyse" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14" -
@@ -20,7 +20,6 @@ describe RequestLogAnalyzer, 'running from command line' do
20
20
  output.any? { |line| /^Parsed requests\:\s*2\s/ =~ line }.should be_true
21
21
  end
22
22
 
23
-
24
23
  it "should skip 1 requests with a --select option" do
25
24
  output = run("#{log_fixture(:rails_1x)} --select controller PeopleController")
26
25
  output.any? { |line| /^Skipped requests\:\s*1\s/ =~ line }.should be_true
@@ -87,4 +86,9 @@ describe RequestLogAnalyzer, 'running from command line' do
87
86
  output = run("--format rails - < #{log_fixture(:rails_1x)}")
88
87
  output.any? { |line| /^Parsed requests\:\s*4\s/ =~ line }.should be_true
89
88
  end
89
+
90
+ it "should accept a directory as a commandline option" do
91
+ output = run("#{log_directory_fixture("s3_logs")} --format amazon_s3")
92
+ output.any? { |line| /^Parsed requests:\s*8\s/ =~ line }.should be_true
93
+ end
90
94
  end
data/spec/lib/helpers.rb CHANGED
@@ -10,6 +10,11 @@ module RequestLogAnalyzer::RSpec::Helpers
10
10
  File.dirname(__FILE__) + "/../fixtures/#{name}.#{extention}"
11
11
  end
12
12
 
13
+ # directory of logs
14
+ def log_directory_fixture(name)
15
+ File.dirname(__FILE__) + "/../fixtures/#{name}"
16
+ end
17
+
13
18
  # Creates a log file given some lines
14
19
  def log_snippet(*lines)
15
20
  StringIO.new(lines.join("\n") << "\n")
@@ -49,12 +54,12 @@ module RequestLogAnalyzer::RSpec::Helpers
49
54
  def temp_output_file(file_type)
50
55
  File.expand_path("#{File.dirname(__FILE__)}/../../tmp/spec.#{file_type}.tmp")
51
56
  end
52
-
57
+
53
58
  # Check if a given string can be found in the given file
54
59
  # Returns the line number if found, nil otherwise
55
60
  def find_string_in_file(string, file, options = {})
56
61
  return nil unless File.exists?(file)
57
-
62
+
58
63
  line_counter = 0
59
64
 
60
65
  File.open( file ) do |io|
@@ -66,7 +71,7 @@ module RequestLogAnalyzer::RSpec::Helpers
66
71
  return line_counter if line.include? string
67
72
  }
68
73
  end
69
-
74
+
70
75
  return nil
71
76
  end
72
77
  end
@@ -5,7 +5,7 @@ describe RequestLogAnalyzer::FileFormat::Rails3 do
5
5
  subject { RequestLogAnalyzer::FileFormat.load(:rails3) }
6
6
 
7
7
  it { should be_well_formed }
8
- it { should have(9).report_trackers }
8
+ it { should have(10).report_trackers }
9
9
 
10
10
  describe '#parse_line' do
11
11
 
@@ -81,6 +81,11 @@ describe RequestLogAnalyzer::FileFormat::Rails3 do
81
81
  :message => "undefined local variable or method `field' for #<Class>",
82
82
  :file => '/Users/willem/Code/warehouse/app/views/queries/execute.csv.erb')
83
83
  end
84
+
85
+ it "should parse :rendered lines as an array" do
86
+ line = " Rendered queries/index.html.erb (0.6ms)"
87
+ subject.should parse_line(line).as(:rendered).and_capture(:partial_duration => [0.0006])
88
+ end
84
89
  end
85
90
 
86
91
  describe '#parse_io' do
@@ -100,7 +105,19 @@ describe RequestLogAnalyzer::FileFormat::Rails3 do
100
105
  log_parser.should_not_receive(:warn)
101
106
  log_parser.parse_string(log)
102
107
  end
103
-
108
+
109
+ it "should count partials correctly" do
110
+ log = <<-EOLOG
111
+ Started GET "/stream_support" for 127.0.0.1 at 2012-11-21 15:21:31 +0100
112
+ Processing by HomeController#stream_support as */*
113
+ Rendered home/stream_support.html.slim (33.2ms)
114
+ Rendered home/stream_support.html.slim (0.0ms)
115
+ Completed 200 OK in 2ms (Views: 0.6ms | ActiveRecord: 0.0ms)
116
+ EOLOG
117
+
118
+ log_parser.parse_string(log)
119
+ end
120
+
104
121
  it "should parse an unroutable request correctly" do
105
122
  log = <<-EOLOG
106
123
  Started GET "/404" for 127.0.0.1 at Fri Mar 19 06:40:57 -0700 2010
@@ -113,10 +130,10 @@ describe RequestLogAnalyzer::FileFormat::Rails3 do
113
130
  EOLOG
114
131
 
115
132
  log_parser.should_receive(:handle_request).once
116
- log_parser.should_not_receive(:warn)
133
+ log_parser.should_receive(:warn).once
117
134
  log_parser.parse_string(log)
118
135
  end
119
-
136
+
120
137
  it "should parse a failing request correctly" do
121
138
  log = <<-EOLOG
122
139
  Started POST "/queries/397638749/execute.csv" for 127.0.0.1 at Mon Mar 01 18:44:33 -0800 2010
@@ -142,7 +159,7 @@ describe RequestLogAnalyzer::FileFormat::Rails3 do
142
159
  EOLOG
143
160
 
144
161
  log_parser.should_receive(:handle_request).once
145
- log_parser.should_not_receive(:warn)
162
+ log_parser.should_receive(:warn).exactly(3).times
146
163
  log_parser.parse_string(log)
147
164
  end
148
165
  end
@@ -24,6 +24,13 @@ describe RequestLogAnalyzer::Tracker::Duration do
24
24
  lambda { @tracker.report(mock_output) }.should_not raise_error
25
25
  end
26
26
 
27
+ it "should generate a report with arrays of durations are present" do
28
+ @tracker.update(request(:category => 'a', :duration => [0.1, 0.2]))
29
+ @tracker.update(request(:category => 'a', :duration => [0.2, 0.3]))
30
+ lambda { @tracker.report(mock_output) }.should_not raise_error
31
+ @tracker.to_yaml_object['a'].should include(:min => 0.1, :hits => 4, :max => 0.3, :mean => 0.2, :sum => 0.8)
32
+ end
33
+
27
34
  it "should generate a YAML output" do
28
35
  @tracker.update(request(:category => 'a', :duration => 0.2))
29
36
  @tracker.update(request(:category => 'b', :duration => 0.2))
metadata CHANGED
@@ -1,83 +1,100 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: request-log-analyzer
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 12
8
- - 5
9
- version: 1.12.5
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.12.6
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Willem van Bergen
13
9
  - Bart ten Brinke
14
10
  autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
-
18
- date: 2012-09-20 00:00:00 -04:00
19
- default_executable: request-log-analyzer
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
13
+ date: 2012-12-10 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: rake
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
31
23
  type: :development
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: rspec
35
24
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
37
- requirements:
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: rspec
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
38
36
  - - ~>
39
- - !ruby/object:Gem::Version
40
- segments:
41
- - 2
42
- - 8
43
- version: "2.8"
37
+ - !ruby/object:Gem::Version
38
+ version: '2.8'
44
39
  type: :development
45
- version_requirements: *id002
46
- - !ruby/object:Gem::Dependency
47
- name: activerecord
48
40
  prerelease: false
49
- requirement: &id003 !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- segments:
54
- - 0
55
- version: "0"
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '2.8'
47
+ - !ruby/object:Gem::Dependency
48
+ name: activerecord
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
56
55
  type: :development
57
- version_requirements: *id003
58
- - !ruby/object:Gem::Dependency
59
- name: sqlite3
60
56
  prerelease: false
61
- requirement: &id004 !ruby/object:Gem::Requirement
62
- requirements:
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- segments:
66
- - 0
67
- version: "0"
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: sqlite3
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
68
71
  type: :development
69
- version_requirements: *id004
70
- description: " Request log analyzer's purpose is to find out how your web application is being used, how it performs and to\n focus your optimization efforts. This tool will parse all requests in the application's log file and aggregate the \n information. Once it is finished parsing the log file(s), it will show the requests that take op most server time \n using various metrics. It can also insert all parsed request information into a database so you can roll your own\n analysis. It supports Rails-, Merb- and Rack-based applications logs, Apache and Amazon S3 access logs and MySQL \n slow query logs out of the box, but file formats of other applications can easily be supported by supplying an \n easy to write log file format definition.\n"
71
- email:
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ description: ! " Request log analyzer's purpose is to find out how your web application
80
+ is being used, how it performs and to\n focus your optimization efforts. This
81
+ tool will parse all requests in the application's log file and aggregate the \n
82
+ \ information. Once it is finished parsing the log file(s), it will show the requests
83
+ that take op most server time \n using various metrics. It can also insert all
84
+ parsed request information into a database so you can roll your own\n analysis.
85
+ It supports Rails-, Merb- and Rack-based applications logs, Apache and Amazon S3
86
+ access logs and MySQL \n slow query logs out of the box, but file formats of
87
+ other applications can easily be supported by supplying an \n easy to write log
88
+ file format definition.\n"
89
+ email:
72
90
  - willem@railsdoctors.com
73
91
  - bart@railsdoctors.com
74
- executables:
92
+ executables:
75
93
  - request-log-analyzer
76
94
  extensions: []
77
-
78
- extra_rdoc_files:
95
+ extra_rdoc_files:
79
96
  - README.rdoc
80
- files:
97
+ files:
81
98
  - .gitignore
82
99
  - .infinity_test
83
100
  - .travis.yml
@@ -92,7 +109,7 @@ files:
92
109
  - lib/cli/database_console_init.rb
93
110
  - lib/cli/progressbar.rb
94
111
  - lib/cli/tools.rb
95
- - lib/ordered_hash.rb
112
+ - lib/other/ordered_hash.rb
96
113
  - lib/request_log_analyzer.rb
97
114
  - lib/request_log_analyzer/aggregator.rb
98
115
  - lib/request_log_analyzer/aggregator/database_inserter.rb
@@ -114,6 +131,7 @@ files:
114
131
  - lib/request_log_analyzer/file_format/haproxy.rb
115
132
  - lib/request_log_analyzer/file_format/merb.rb
116
133
  - lib/request_log_analyzer/file_format/mysql.rb
134
+ - lib/request_log_analyzer/file_format/nginx.rb
117
135
  - lib/request_log_analyzer/file_format/oink.rb
118
136
  - lib/request_log_analyzer/file_format/postgresql.rb
119
137
  - lib/request_log_analyzer/file_format/rack.rb
@@ -164,7 +182,10 @@ files:
164
182
  - spec/fixtures/rails_1x.log
165
183
  - spec/fixtures/rails_22.log
166
184
  - spec/fixtures/rails_22_cached.log
185
+ - spec/fixtures/rails_3_partials.log
167
186
  - spec/fixtures/rails_unordered.log
187
+ - spec/fixtures/s3_logs/2012-10-05-16-18-11-F9AAC5D1A55AEBAD
188
+ - spec/fixtures/s3_logs/2012-10-05-16-26-06-15314AF7F0651839
168
189
  - spec/fixtures/sinatra.log
169
190
  - spec/fixtures/syslog_1x.log
170
191
  - spec/fixtures/test_file_format.log
@@ -221,42 +242,40 @@ files:
221
242
  - spec/unit/tracker/traffic_tracker_spec.rb
222
243
  - tasks/github-gem.rake
223
244
  - tasks/request_log_analyzer.rake
224
- has_rdoc: true
225
245
  homepage: http://railsdoctors.com
226
246
  licenses: []
227
-
228
247
  post_install_message:
229
- rdoc_options:
248
+ rdoc_options:
230
249
  - --title
231
250
  - request-log-analyzer
232
251
  - --main
233
252
  - README.rdoc
234
253
  - --line-numbers
235
254
  - --inline-source
236
- require_paths:
255
+ require_paths:
237
256
  - lib
238
- required_ruby_version: !ruby/object:Gem::Requirement
239
- requirements:
240
- - - ">="
241
- - !ruby/object:Gem::Version
242
- segments:
243
- - 0
244
- version: "0"
245
- required_rubygems_version: !ruby/object:Gem::Requirement
246
- requirements:
247
- - - ">="
248
- - !ruby/object:Gem::Version
249
- segments:
250
- - 0
251
- version: "0"
252
- requirements:
253
- - To use the database inserter, ActiveRecord and an appropriate database adapter are required.
257
+ required_ruby_version: !ruby/object:Gem::Requirement
258
+ none: false
259
+ requirements:
260
+ - - ! '>='
261
+ - !ruby/object:Gem::Version
262
+ version: '0'
263
+ required_rubygems_version: !ruby/object:Gem::Requirement
264
+ none: false
265
+ requirements:
266
+ - - ! '>='
267
+ - !ruby/object:Gem::Version
268
+ version: '0'
269
+ requirements:
270
+ - To use the database inserter, ActiveRecord and an appropriate database adapter are
271
+ required.
254
272
  rubyforge_project: r-l-a
255
- rubygems_version: 1.3.6
273
+ rubygems_version: 1.8.24
256
274
  signing_key:
257
275
  specification_version: 3
258
- summary: A command line tool to analyze request logs for Apache, Rails, Merb, MySQL and other web application servers
259
- test_files:
276
+ summary: A command line tool to analyze request logs for Apache, Rails, Merb, MySQL
277
+ and other web application servers
278
+ test_files:
260
279
  - spec/integration/command_line_usage_spec.rb
261
280
  - spec/integration/mailer_spec.rb
262
281
  - spec/integration/munin_plugins_rails_spec.rb