request-log-analyzer 1.2.1 → 1.2.6
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.
- data/.gitignore +10 -0
- data/Rakefile +3 -1
- data/lib/request_log_analyzer/aggregator/database.rb +79 -46
- data/lib/request_log_analyzer/controller.rb +12 -7
- data/lib/request_log_analyzer/file_format/merb.rb +5 -7
- data/lib/request_log_analyzer/line_definition.rb +9 -0
- data/lib/request_log_analyzer/request.rb +2 -2
- data/lib/request_log_analyzer/source/log_parser.rb +4 -0
- data/lib/request_log_analyzer.rb +1 -1
- data/request-log-analyzer.gemspec +36 -0
- data/spec/fixtures/header_and_footer.log +6 -0
- data/spec/fixtures/merb_prefixed.log +9 -0
- data/spec/integration/command_line_usage_spec.rb +0 -2
- data/spec/lib/{helper.rb → helpers.rb} +1 -3
- data/spec/lib/macros.rb +2 -0
- data/spec/lib/matchers.rb +63 -0
- data/spec/lib/mocks.rb +12 -1
- data/spec/lib/testing_format.rb +6 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +13 -4
- data/spec/unit/aggregator/database_spec.rb +234 -0
- data/spec/unit/aggregator/summarizer_spec.rb +0 -2
- data/spec/unit/controller/controller_spec.rb +0 -2
- data/spec/unit/controller/log_processor_spec.rb +0 -2
- data/spec/unit/file_format/file_format_api_spec.rb +50 -71
- data/spec/unit/file_format/line_definition_spec.rb +49 -45
- data/spec/unit/file_format/merb_format_spec.rb +20 -2
- data/spec/unit/file_format/rails_format_spec.rb +0 -2
- data/spec/unit/filter/anonymize_filter_spec.rb +0 -1
- data/spec/unit/filter/field_filter_spec.rb +0 -3
- data/spec/unit/filter/filter_spec.rb +17 -0
- data/spec/unit/filter/timespan_filter_spec.rb +0 -3
- data/spec/unit/source/log_parser_spec.rb +5 -4
- data/spec/unit/source/request_spec.rb +91 -52
- data/spec/unit/tracker/duration_tracker_spec.rb +0 -6
- data/spec/unit/tracker/frequency_tracker_spec.rb +0 -6
- data/spec/unit/tracker/hourly_spread_spec.rb +0 -4
- data/spec/unit/tracker/timespan_tracker_spec.rb +0 -4
- data/spec/unit/tracker/tracker_api_spec.rb +0 -2
- data/tasks/github-gem.rake +199 -192
- metadata +120 -92
- data/RELEASE_NOTES.rdoc +0 -10
- data/spec/unit/aggregator/database_inserter_spec.rb +0 -106
- data/tasks/rspec.rake +0 -12
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
2
|
|
|
3
3
|
describe RequestLogAnalyzer::Source::LogParser, :requests do
|
|
4
|
-
include RequestLogAnalyzer::Spec::Helper
|
|
5
4
|
|
|
6
5
|
before(:each) do
|
|
7
6
|
@log_parser = RequestLogAnalyzer::Source::LogParser.new(testing_format)
|
|
@@ -42,12 +41,15 @@ describe RequestLogAnalyzer::Source::LogParser, :requests do
|
|
|
42
41
|
request[:test_capture].should_not be_nil
|
|
43
42
|
end
|
|
44
43
|
io.close
|
|
45
|
-
end
|
|
44
|
+
end
|
|
46
45
|
|
|
46
|
+
it "should parse a request that only consists of one line" do
|
|
47
|
+
@log_parser.parse_file(log_fixture(:header_and_footer))
|
|
48
|
+
@log_parser.parsed_requests.should == 2
|
|
49
|
+
end
|
|
47
50
|
end
|
|
48
51
|
|
|
49
52
|
describe RequestLogAnalyzer::Source::LogParser, :warnings do
|
|
50
|
-
include RequestLogAnalyzer::Spec::Helper
|
|
51
53
|
|
|
52
54
|
before(:each) do
|
|
53
55
|
@log_parser = RequestLogAnalyzer::Source::LogParser.new(testing_format, :parse_strategy => 'cautious')
|
|
@@ -67,7 +69,6 @@ describe RequestLogAnalyzer::Source::LogParser, :warnings do
|
|
|
67
69
|
end
|
|
68
70
|
|
|
69
71
|
describe RequestLogAnalyzer::Source::LogParser, :decompression do
|
|
70
|
-
include RequestLogAnalyzer::Spec::Helper
|
|
71
72
|
|
|
72
73
|
before(:each) do
|
|
73
74
|
@log_parser = RequestLogAnalyzer::Source::LogParser.new(RequestLogAnalyzer::FileFormat::Rails.new)
|
|
@@ -1,72 +1,111 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
2
|
|
|
3
|
-
describe RequestLogAnalyzer::Request
|
|
4
|
-
|
|
5
|
-
include RequestLogAnalyzer::Spec::Helper
|
|
3
|
+
describe RequestLogAnalyzer::Request do
|
|
6
4
|
|
|
7
5
|
before(:each) do
|
|
8
|
-
@
|
|
9
|
-
@incomplete_request << { :line_type => :test, :lineno => 1, :test_capture => 'awesome!' }
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "should be single if only one line has been added" do
|
|
13
|
-
@incomplete_request.should_not be_empty
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should not be a completed request" do
|
|
17
|
-
@incomplete_request.should_not be_completed
|
|
6
|
+
@request = testing_format.request
|
|
18
7
|
end
|
|
19
8
|
|
|
20
|
-
it "should
|
|
21
|
-
@
|
|
22
|
-
@incomplete_request.should =~ :test
|
|
9
|
+
it "should be empty without any captured lines in it" do
|
|
10
|
+
@request.should be_empty
|
|
23
11
|
end
|
|
24
12
|
|
|
25
|
-
|
|
26
|
-
@incomplete_request[:test_capture].should == 'awesome!'
|
|
27
|
-
end
|
|
13
|
+
context :incomplete do
|
|
28
14
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
describe RequestLogAnalyzer::Request, :completed_request do
|
|
15
|
+
before(:each) do
|
|
16
|
+
@request << { :line_type => :test, :lineno => 1, :test_capture => 'awesome!' }
|
|
17
|
+
end
|
|
36
18
|
|
|
37
|
-
|
|
19
|
+
it "should be single if only one line has been added" do
|
|
20
|
+
@request.should_not be_empty
|
|
21
|
+
end
|
|
38
22
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@completed_request << { :line_type => :test, :lineno => 4, :test_capture => 'testing' }
|
|
43
|
-
@completed_request << { :line_type => :test, :lineno => 7, :test_capture => 'testing some more' }
|
|
44
|
-
@completed_request << { :line_type => :last, :lineno => 10, :time => 0.03 }
|
|
45
|
-
end
|
|
23
|
+
it "should not be a completed request" do
|
|
24
|
+
@request.should_not be_completed
|
|
25
|
+
end
|
|
46
26
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
27
|
+
it "should take the line type of the first line as global line_type" do
|
|
28
|
+
@request.lines[0][:line_type].should == :test
|
|
29
|
+
@request.should =~ :test
|
|
30
|
+
end
|
|
50
31
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
32
|
+
it "should return the first field value" do
|
|
33
|
+
@request[:test_capture].should == 'awesome!'
|
|
34
|
+
end
|
|
54
35
|
|
|
55
|
-
|
|
56
|
-
|
|
36
|
+
it "should return nil if no such field is present" do
|
|
37
|
+
@request[:nonexisting].should be_nil
|
|
38
|
+
end
|
|
57
39
|
end
|
|
58
40
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
41
|
+
context :completed do
|
|
42
|
+
|
|
43
|
+
before(:each) do
|
|
44
|
+
@request << { :line_type => :first, :lineno => 1, :name => 'first line!' }
|
|
45
|
+
@request << { :line_type => :test, :lineno => 4, :test_capture => 'testing' }
|
|
46
|
+
@request << { :line_type => :test, :lineno => 7, :test_capture => 'testing some more' }
|
|
47
|
+
@request << { :line_type => :last, :lineno => 10, :time => 0.03 }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should not be empty when multiple liness are added" do
|
|
51
|
+
@request.should_not be_empty
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should be a completed request" do
|
|
55
|
+
@request.should be_completed
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should recognize all line types" do
|
|
59
|
+
[:first, :test, :last].each { |type| @request.should =~ type }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should detect the correct field value" do
|
|
63
|
+
@request[:name].should == 'first line!'
|
|
64
|
+
@request[:time].should == 0.03
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "should detect the first matching field value" do
|
|
68
|
+
@request.first(:test_capture).should == 'testing'
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "should detect the every matching field value" do
|
|
72
|
+
@request.every(:test_capture).should == ['testing', "testing some more"]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "should set the first_lineno for a request to the lowest lineno encountered" do
|
|
76
|
+
@request.first_lineno.should eql(1)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "should set the first_lineno for a request if a line with a lower lineno is added" do
|
|
80
|
+
@request << { :line_type => :test, :lineno => 0 }
|
|
81
|
+
@request.first_lineno.should eql(0)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "should set the last_lineno for a request to the highest encountered lineno" do
|
|
85
|
+
@request.last_lineno.should eql(10)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "should not set the last_lineno for a request if a line with a lower lineno is added" do
|
|
89
|
+
@request << { :line_type => :test, :lineno => 7 }
|
|
90
|
+
@request.last_lineno.should eql(10)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "should not have a timestamp if no such field is captured" do
|
|
94
|
+
@request.timestamp.should be_nil
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "should set return a timestamp field if such a field is captured" do
|
|
98
|
+
@request << { :line_type => :first, :lineno => 1, :name => 'first line!', :timestamp => Time.now}
|
|
99
|
+
@request.timestamp.should_not be_nil
|
|
100
|
+
end
|
|
62
101
|
end
|
|
63
102
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
103
|
+
context 'single line' do
|
|
104
|
+
# combined is both a header and a footer line
|
|
105
|
+
before(:each) { @request << { :line_type => :combined, :lineno => 1 } }
|
|
67
106
|
|
|
68
|
-
|
|
69
|
-
|
|
107
|
+
it "should be a completed request if the line is both header and footer" do
|
|
108
|
+
@request.should be_completed
|
|
109
|
+
end
|
|
70
110
|
end
|
|
71
|
-
|
|
72
|
-
end
|
|
111
|
+
end
|
|
@@ -2,8 +2,6 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe RequestLogAnalyzer::Tracker::Duration, 'static category' do
|
|
4
4
|
|
|
5
|
-
include RequestLogAnalyzer::Spec::Helper
|
|
6
|
-
|
|
7
5
|
before(:each) do
|
|
8
6
|
@tracker = RequestLogAnalyzer::Tracker::Duration.new(:duration => :duration, :category => :category)
|
|
9
7
|
@tracker.prepare
|
|
@@ -54,8 +52,6 @@ end
|
|
|
54
52
|
|
|
55
53
|
describe RequestLogAnalyzer::Tracker::Duration, 'dynamic category' do
|
|
56
54
|
|
|
57
|
-
include RequestLogAnalyzer::Spec::Helper
|
|
58
|
-
|
|
59
55
|
before(:each) do
|
|
60
56
|
@categorizer = Proc.new { |request| request[:duration] > 0.2 ? 'slow' : 'fast' }
|
|
61
57
|
@tracker = RequestLogAnalyzer::Tracker::Duration.new(:duration => :duration, :category => @categorizer)
|
|
@@ -75,8 +71,6 @@ end
|
|
|
75
71
|
|
|
76
72
|
describe RequestLogAnalyzer::Tracker::Duration, 'reporting' do
|
|
77
73
|
|
|
78
|
-
include RequestLogAnalyzer::Spec::Helper
|
|
79
|
-
|
|
80
74
|
before(:each) do
|
|
81
75
|
@tracker = RequestLogAnalyzer::Tracker::Duration.new(:category => :category, :duration => :duration)
|
|
82
76
|
@tracker.prepare
|
|
@@ -2,8 +2,6 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe RequestLogAnalyzer::Tracker::Frequency, 'static category' do
|
|
4
4
|
|
|
5
|
-
include RequestLogAnalyzer::Spec::Helper
|
|
6
|
-
|
|
7
5
|
before(:each) do
|
|
8
6
|
@tracker = RequestLogAnalyzer::Tracker::Frequency.new(:category => :category)
|
|
9
7
|
@tracker.prepare
|
|
@@ -36,8 +34,6 @@ end
|
|
|
36
34
|
|
|
37
35
|
describe RequestLogAnalyzer::Tracker::Frequency, 'dynamic category' do
|
|
38
36
|
|
|
39
|
-
include RequestLogAnalyzer::Spec::Helper
|
|
40
|
-
|
|
41
37
|
before(:each) do
|
|
42
38
|
@categorizer = Proc.new { |request| request[:duration] > 0.2 ? 'slow' : 'fast' }
|
|
43
39
|
@tracker = RequestLogAnalyzer::Tracker::Frequency.new(:category => @categorizer)
|
|
@@ -59,8 +55,6 @@ end
|
|
|
59
55
|
|
|
60
56
|
describe RequestLogAnalyzer::Tracker::Frequency, 'reporting' do
|
|
61
57
|
|
|
62
|
-
include RequestLogAnalyzer::Spec::Helper
|
|
63
|
-
|
|
64
58
|
before(:each) do
|
|
65
59
|
@tracker = RequestLogAnalyzer::Tracker::Frequency.new(:category => :category)
|
|
66
60
|
@tracker.prepare
|
|
@@ -2,8 +2,6 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe RequestLogAnalyzer::Tracker::HourlySpread do
|
|
4
4
|
|
|
5
|
-
include RequestLogAnalyzer::Spec::Helper
|
|
6
|
-
|
|
7
5
|
before(:each) do
|
|
8
6
|
@tracker = RequestLogAnalyzer::Tracker::HourlySpread.new
|
|
9
7
|
@tracker.prepare
|
|
@@ -54,8 +52,6 @@ end
|
|
|
54
52
|
|
|
55
53
|
describe RequestLogAnalyzer::Tracker::HourlySpread, 'reporting' do
|
|
56
54
|
|
|
57
|
-
include RequestLogAnalyzer::Spec::Helper
|
|
58
|
-
|
|
59
55
|
before(:each) do
|
|
60
56
|
@tracker = RequestLogAnalyzer::Tracker::HourlySpread.new
|
|
61
57
|
@tracker.prepare
|
|
@@ -2,8 +2,6 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe RequestLogAnalyzer::Tracker::Timespan do
|
|
4
4
|
|
|
5
|
-
include RequestLogAnalyzer::Spec::Helper
|
|
6
|
-
|
|
7
5
|
before(:each) do
|
|
8
6
|
@tracker = RequestLogAnalyzer::Tracker::Timespan.new
|
|
9
7
|
@tracker.prepare
|
|
@@ -45,8 +43,6 @@ end
|
|
|
45
43
|
|
|
46
44
|
describe RequestLogAnalyzer::Tracker::Timespan, 'reporting' do
|
|
47
45
|
|
|
48
|
-
include RequestLogAnalyzer::Spec::Helper
|
|
49
|
-
|
|
50
46
|
before(:each) do
|
|
51
47
|
@tracker = RequestLogAnalyzer::Tracker::Timespan.new
|
|
52
48
|
@tracker.prepare
|