request-log-analyzer 1.12.7 → 1.12.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,18 +13,18 @@ module RequestLogAnalyzer::FileFormat
|
|
13
13
|
line.header = true
|
14
14
|
line.teaser = /Started /
|
15
15
|
line.regexp = /Started ([A-Z]+) "([^"]+)" for (#{ip_address}) at (#{timestamp('%a %b %d %H:%M:%S %z %Y')}|#{timestamp('%Y-%m-%d %H:%M:%S %z')})/
|
16
|
-
|
16
|
+
|
17
17
|
line.capture(:method)
|
18
18
|
line.capture(:path)
|
19
19
|
line.capture(:ip)
|
20
20
|
line.capture(:timestamp).as(:timestamp)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
# Processing by QueriesController#index as HTML
|
24
24
|
line_definition :processing do |line|
|
25
25
|
line.teaser = /Processing by /
|
26
26
|
line.regexp = /Processing by ([A-Za-z0-9\-:]+)\#(\w+) as ([\w\/\*]*)/
|
27
|
-
|
27
|
+
|
28
28
|
line.capture(:controller)
|
29
29
|
line.capture(:action)
|
30
30
|
line.capture(:format)
|
@@ -36,7 +36,7 @@ module RequestLogAnalyzer::FileFormat
|
|
36
36
|
line.regexp = / Parameters:\s+(\{.*\})/
|
37
37
|
line.capture(:params).as(:eval)
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
# Completed 200 OK in 224ms (Views: 200.2ms | ActiveRecord: 3.4ms)
|
41
41
|
# Completed 302 Found in 23ms
|
42
42
|
# Completed in 189ms
|
@@ -44,13 +44,21 @@ module RequestLogAnalyzer::FileFormat
|
|
44
44
|
line.footer = true
|
45
45
|
line.teaser = /Completed /
|
46
46
|
line.regexp = /Completed (\d+)? .*in (\d+(?:\.\d+)?)ms(?:[^\(]*\(Views: (\d+(?:\.\d+)?)ms .* ActiveRecord: (\d+(?:\.\d+)?)ms.*\))?/
|
47
|
-
|
47
|
+
|
48
48
|
line.capture(:status).as(:integer)
|
49
49
|
line.capture(:duration).as(:duration, :unit => :msec)
|
50
50
|
line.capture(:view).as(:duration, :unit => :msec)
|
51
51
|
line.capture(:db).as(:duration, :unit => :msec)
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
|
+
# ActionController::RoutingError (No route matches [GET] "/missing_stuff"):
|
55
|
+
line_definition :routing_errors do |line|
|
56
|
+
line.teaser = /RoutingError/
|
57
|
+
line.regexp = /No route matches \[([A-Z]+)\] "([^"]+)"/
|
58
|
+
line.capture(:missing_resource_method).as(:string)
|
59
|
+
line.capture(:missing_resource).as(:string)
|
60
|
+
end
|
61
|
+
|
54
62
|
# ActionView::Template::Error (undefined local variable or method `field' for #<Class>) on line #3 of /Users/willem/Code/warehouse/app/views/queries/execute.csv.erb:
|
55
63
|
line_definition :failure do |line|
|
56
64
|
line.footer = true
|
@@ -77,29 +85,32 @@ module RequestLogAnalyzer::FileFormat
|
|
77
85
|
# Rendered collection (0.0ms)
|
78
86
|
|
79
87
|
REQUEST_CATEGORIZER = lambda { |request| "#{request[:controller]}##{request[:action]}.#{request[:format]}" }
|
80
|
-
|
88
|
+
|
81
89
|
report do |analyze|
|
82
|
-
|
90
|
+
|
83
91
|
analyze.timespan
|
84
92
|
analyze.hourly_spread
|
85
|
-
|
93
|
+
|
86
94
|
analyze.frequency :category => REQUEST_CATEGORIZER, :title => 'Most requested'
|
87
95
|
analyze.frequency :method, :title => 'HTTP methods'
|
88
96
|
analyze.frequency :status, :title => 'HTTP statuses returned'
|
89
|
-
|
97
|
+
|
90
98
|
analyze.duration :duration, :category => REQUEST_CATEGORIZER, :title => "Request duration", :line_type => :completed
|
91
99
|
analyze.duration :partial_duration, :category => :rendered_file, :title => 'Partials rendering time', :line_type => :rendered
|
92
100
|
analyze.duration :view, :category => REQUEST_CATEGORIZER, :title => "View rendering time", :line_type => :completed
|
93
101
|
analyze.duration :db, :category => REQUEST_CATEGORIZER, :title => "Database time", :line_type => :completed
|
94
|
-
|
102
|
+
|
95
103
|
analyze.frequency :category => REQUEST_CATEGORIZER, :title => 'Process blockers (> 1 sec duration)',
|
96
104
|
:if => lambda { |request| request[:duration] && request[:duration] > 1.0 }
|
105
|
+
|
106
|
+
analyze.frequency :category => lambda{|x| "[#{x[:missing_resource_method]}] #{x[:missing_resource]}"},
|
107
|
+
:title => "Routing Errors", :if => lambda{ |request| !request[:missing_resource].nil? }
|
97
108
|
end
|
98
|
-
|
109
|
+
|
99
110
|
class Request < RequestLogAnalyzer::Request
|
100
111
|
# Used to handle conversion of abbrev. month name to a digit
|
101
112
|
MONTHS = %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
|
102
|
-
|
113
|
+
|
103
114
|
def convert_timestamp(value, definition)
|
104
115
|
# the time value can be in 2 formats:
|
105
116
|
# - 2010-10-26 02:27:15 +0000 (ruby 1.9.2)
|
data/lib/request_log_analyzer.rb
CHANGED
@@ -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.
|
14
|
+
VERSION = "1.12.8"
|
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
|
@@ -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.
|
6
|
-
s.date = "2013-01-
|
5
|
+
s.version = "1.12.8"
|
6
|
+
s.date = "2013-01-22"
|
7
7
|
|
8
8
|
s.rubyforge_project = 'r-l-a'
|
9
9
|
|
@@ -3,24 +3,24 @@ require 'spec_helper'
|
|
3
3
|
describe RequestLogAnalyzer::FileFormat::Rails3 do
|
4
4
|
|
5
5
|
subject { RequestLogAnalyzer::FileFormat.load(:rails3) }
|
6
|
-
|
6
|
+
|
7
7
|
it { should be_well_formed }
|
8
|
-
it { should have(
|
9
|
-
|
8
|
+
it { should have(11).report_trackers }
|
9
|
+
|
10
10
|
describe '#parse_line' do
|
11
11
|
|
12
12
|
it "should parse :started lines correctly" do
|
13
13
|
line = 'Started GET "/queries" for 127.0.0.1 at Thu Feb 25 16:15:18 -0800 2010'
|
14
|
-
subject.should parse_line(line).as(:started).and_capture(:method => 'GET',
|
14
|
+
subject.should parse_line(line).as(:started).and_capture(:method => 'GET',
|
15
15
|
:path => '/queries', :ip => '127.0.0.1', :timestamp => 20100225161518)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should parse :started lines in Oct, Nov and Dec correctly" do
|
19
19
|
line = 'Started GET "/queries" for 127.0.0.1 at Thu Oct 25 16:15:18 -0800 2010'
|
20
20
|
subject.should parse_line(line).as(:started).and_capture(:method => 'GET',
|
21
21
|
:path => '/queries', :ip => '127.0.0.1', :timestamp => 20101025161518)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
it "should parse :started lines in Ruby 1.9.2 format correctly" do
|
25
25
|
line = 'Started GET "/queries" for 127.0.0.1 at 2010-10-26 02:27:15 +0000'
|
26
26
|
subject.should parse_line(line).as(:started).and_capture(:method => 'GET',
|
@@ -32,13 +32,13 @@ describe RequestLogAnalyzer::FileFormat::Rails3 do
|
|
32
32
|
subject.should parse_line(line).as(:processing).and_capture(
|
33
33
|
:controller => 'QueriesController', :action => 'index', :format => 'HTML')
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
it "should parse nested :processing lines correctly" do
|
37
37
|
line = ' Processing by Projects::QueriesController#index as HTML'
|
38
38
|
subject.should parse_line(line).as(:processing).and_capture(
|
39
39
|
:controller => 'Projects::QueriesController', :action => 'index', :format => 'HTML')
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
it "should parse :processing lines correctly with format */*" do
|
43
43
|
line = ' Processing by ProjectsController#avatar as */*'
|
44
44
|
subject.should parse_line(line).as(:processing).and_capture(
|
@@ -55,30 +55,35 @@ describe RequestLogAnalyzer::FileFormat::Rails3 do
|
|
55
55
|
line = ' Parameters: {"action"=>"cached", "controller"=>"cached"}'
|
56
56
|
subject.should parse_line(line).as(:parameters).and_capture(:params => {:action => 'cached', :controller => 'cached'})
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
it "should parse :completed lines correctly" do
|
60
60
|
line = 'Completed 200 OK in 170ms (Views: 78.0ms | ActiveRecord: 48.2ms)'
|
61
61
|
subject.should parse_line(line).as(:completed).and_capture(
|
62
62
|
:duration => 0.170, :view => 0.078, :db => 0.0482, :status => 200)
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
it "should parse :completed lines correctly when ActiveRecord is not mentioned" do
|
66
66
|
line = 'Completed 200 OK in 364ms (Views: 31.4ms)'
|
67
67
|
subject.should parse_line(line).as(:completed).and_capture(:duration => 0.364, :status => 200)
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
it "should parse :completed lines correctly when other durations are specified" do
|
71
71
|
line = 'Completed 200 OK in 384ms (Views: 222.0ms | ActiveRecord: 121.0ms | Sphinx: 0.0ms)'
|
72
|
-
subject.should parse_line(line).as(:completed).and_capture(:duration => 0.384, :view => 0.222,
|
72
|
+
subject.should parse_line(line).as(:completed).and_capture(:duration => 0.384, :view => 0.222,
|
73
73
|
:db => 0.121, :status => 200)
|
74
74
|
end
|
75
|
-
|
76
75
|
|
77
|
-
it "should
|
76
|
+
it "should parse :routing_error lines correctly" do
|
77
|
+
line = "ActionController::RoutingError (No route matches [GET] \"/static/faq\"):"
|
78
|
+
subject.should parse_line(line).as(:routing_errors).and_capture(:missing_resource_method => "GET",
|
79
|
+
:missing_resource => '/static/faq')
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should parse :failure lines correctly" do
|
78
83
|
line = "ActionView::Template::Error (undefined local variable or method `field' for #<Class>) on line #3 of /Users/willem/Code/warehouse/app/views/queries/execute.csv.erb:"
|
79
|
-
subject.should parse_line(line).as(:failure).and_capture(:line => 3,
|
80
|
-
:error => 'ActionView::Template::Error',
|
81
|
-
:message => "undefined local variable or method `field' for #<Class>",
|
84
|
+
subject.should parse_line(line).as(:failure).and_capture(:line => 3,
|
85
|
+
:error => 'ActionView::Template::Error',
|
86
|
+
:message => "undefined local variable or method `field' for #<Class>",
|
82
87
|
:file => '/Users/willem/Code/warehouse/app/views/queries/execute.csv.erb')
|
83
88
|
end
|
84
89
|
|
@@ -87,7 +92,7 @@ describe RequestLogAnalyzer::FileFormat::Rails3 do
|
|
87
92
|
subject.should parse_line(line).as(:rendered).and_capture(:partial_duration => [0.0006])
|
88
93
|
end
|
89
94
|
end
|
90
|
-
|
95
|
+
|
91
96
|
describe '#parse_io' do
|
92
97
|
let(:log_parser) { RequestLogAnalyzer::Source::LogParser.new(subject) }
|
93
98
|
|
@@ -100,7 +105,7 @@ describe RequestLogAnalyzer::FileFormat::Rails3 do
|
|
100
105
|
Rendered queries/index.html.erb within layouts/default (40.9ms)
|
101
106
|
Completed 200 OK in 170ms (Views: 78.4ms | ActiveRecord: 48.2ms)
|
102
107
|
EOLOG
|
103
|
-
|
108
|
+
|
104
109
|
log_parser.should_receive(:handle_request).once
|
105
110
|
log_parser.should_not_receive(:warn)
|
106
111
|
log_parser.parse_string(log)
|
@@ -118,22 +123,6 @@ describe RequestLogAnalyzer::FileFormat::Rails3 do
|
|
118
123
|
log_parser.parse_string(log)
|
119
124
|
end
|
120
125
|
|
121
|
-
it "should parse an unroutable request correctly" do
|
122
|
-
log = <<-EOLOG
|
123
|
-
Started GET "/404" for 127.0.0.1 at Fri Mar 19 06:40:57 -0700 2010
|
124
|
-
|
125
|
-
ActionController::RoutingError (No route matches "/404"):
|
126
|
-
|
127
|
-
|
128
|
-
Rendered /Users/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.0ms)
|
129
|
-
|
130
|
-
EOLOG
|
131
|
-
|
132
|
-
log_parser.should_receive(:handle_request).once
|
133
|
-
log_parser.should_receive(:warn).once
|
134
|
-
log_parser.parse_string(log)
|
135
|
-
end
|
136
|
-
|
137
126
|
it "should parse a failing request correctly" do
|
138
127
|
log = <<-EOLOG
|
139
128
|
Started POST "/queries/397638749/execute.csv" for 127.0.0.1 at Mon Mar 01 18:44:33 -0800 2010
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: request-log-analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.
|
4
|
+
version: 1.12.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-01-
|
13
|
+
date: 2013-01-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|