request-log-analyzer 1.5.2 → 1.5.3
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/bin/request-log-analyzer +9 -5
- data/lib/request_log_analyzer.rb +1 -1
- data/lib/request_log_analyzer/aggregator/echo.rb +2 -1
- data/lib/request_log_analyzer/aggregator/summarizer.rb +5 -37
- data/lib/request_log_analyzer/controller.rb +4 -3
- data/lib/request_log_analyzer/file_format.rb +68 -1
- data/lib/request_log_analyzer/file_format/amazon_s3.rb +3 -1
- data/lib/request_log_analyzer/file_format/apache.rb +7 -2
- data/lib/request_log_analyzer/file_format/merb.rb +3 -1
- data/lib/request_log_analyzer/file_format/mysql.rb +10 -5
- data/lib/request_log_analyzer/file_format/rack.rb +1 -3
- data/lib/request_log_analyzer/file_format/rails.rb +5 -5
- data/lib/request_log_analyzer/output.rb +4 -0
- data/lib/request_log_analyzer/output/fancy_html.rb +31 -0
- data/lib/request_log_analyzer/tracker.rb +0 -105
- data/lib/request_log_analyzer/tracker/duration.rb +3 -62
- data/lib/request_log_analyzer/tracker/frequency.rb +18 -5
- data/lib/request_log_analyzer/tracker/numeric_value.rb +223 -0
- data/lib/request_log_analyzer/tracker/traffic.rb +6 -72
- data/request-log-analyzer.gemspec +4 -4
- data/spec/lib/mocks.rb +1 -0
- data/spec/unit/file_format/common_regular_expressions_spec.rb +53 -0
- data/spec/unit/file_format/mysql_format_spec.rb +1 -2
- data/spec/unit/file_format/rails_format_spec.rb +9 -4
- data/spec/unit/tracker/duration_tracker_spec.rb +2 -83
- data/spec/unit/tracker/{count_tracker_spec.rb → numeric_value_tracker_spec.rb} +50 -7
- data/spec/unit/tracker/tracker_api_spec.rb +3 -2
- data/spec/unit/tracker/traffic_tracker_spec.rb +0 -79
- metadata +8 -5
- data/lib/request_log_analyzer/tracker/count.rb +0 -93
@@ -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.5.
|
6
|
-
s.date = "2009-12-
|
5
|
+
s.version = "1.5.3"
|
6
|
+
s.date = "2009-12-14"
|
7
7
|
|
8
8
|
s.rubyforge_project = 'r-l-a'
|
9
9
|
|
@@ -36,6 +36,6 @@ Gem::Specification.new do |s|
|
|
36
36
|
|
37
37
|
# The files and test_files directives are set automatically by the release script.
|
38
38
|
# Do not change them by hand, but make sure to add the files to the git repository.
|
39
|
-
s.files = %w(spec/unit/tracker/hourly_spread_spec.rb lib/request_log_analyzer/output/html.rb DESIGN.rdoc spec/fixtures/rails_unordered.log spec/fixtures/multiple_files_1.log lib/request_log_analyzer/database/source.rb README.rdoc spec/unit/file_format/amazon_s3_format_spec.rb lib/request_log_analyzer/file_format/rails_development.rb spec/fixtures/rails_22.log spec/fixtures/test_order.log spec/unit/database/base_class_spec.rb lib/request_log_analyzer/database/connection.rb lib/request_log_analyzer/aggregator.rb spec/fixtures/decompression.log lib/request_log_analyzer/file_format/apache.rb spec/unit/file_format/rack_format_spec.rb spec/fixtures/decompression.log.gz lib/request_log_analyzer/tracker/frequency.rb lib/request_log_analyzer/tracker/duration.rb tasks/github-gem.rake .gitignore spec/unit/filter/filter_spec.rb spec/lib/macros.rb spec/spec_helper.rb spec/
|
40
|
-
s.test_files = %w(spec/unit/tracker/hourly_spread_spec.rb spec/unit/file_format/amazon_s3_format_spec.rb spec/unit/database/base_class_spec.rb spec/unit/file_format/rack_format_spec.rb spec/unit/filter/filter_spec.rb spec/unit/
|
39
|
+
s.files = %w(spec/unit/tracker/hourly_spread_spec.rb lib/request_log_analyzer/output/html.rb DESIGN.rdoc spec/fixtures/rails_unordered.log spec/fixtures/multiple_files_1.log lib/request_log_analyzer/database/source.rb README.rdoc spec/unit/file_format/amazon_s3_format_spec.rb lib/request_log_analyzer/file_format/rails_development.rb spec/fixtures/rails_22.log spec/fixtures/test_order.log spec/unit/database/base_class_spec.rb lib/request_log_analyzer/database/connection.rb lib/request_log_analyzer/aggregator.rb spec/fixtures/decompression.log lib/request_log_analyzer/file_format/apache.rb spec/unit/file_format/rack_format_spec.rb spec/fixtures/decompression.log.gz lib/request_log_analyzer/tracker/frequency.rb lib/request_log_analyzer/tracker/duration.rb tasks/github-gem.rake .gitignore spec/unit/filter/filter_spec.rb spec/lib/macros.rb spec/spec_helper.rb spec/fixtures/decompression.log.bz2 spec/unit/database/connection_spec.rb lib/request_log_analyzer/filter.rb spec/integration/scout_spec.rb spec/fixtures/test_file_format.log lib/request_log_analyzer/tracker/traffic.rb spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/format_autodetection_spec.rb spec/unit/filter/timespan_filter_spec.rb spec/unit/file_format/file_format_api_spec.rb lib/request_log_analyzer/filter/field.rb lib/request_log_analyzer/file_format/merb.rb lib/request_log_analyzer/filter/anonymize.rb lib/request_log_analyzer/file_format/amazon_s3.rb lib/cli/database_console.rb spec/integration/mailer_spec.rb lib/request_log_analyzer/line_definition.rb spec/unit/tracker/frequency_tracker_spec.rb spec/fixtures/multiple_files_2.log spec/lib/mocks.rb spec/unit/file_format/apache_format_spec.rb spec/fixtures/syslog_1x.log spec/integration/munin_plugins_rails_spec.rb spec/lib/helpers.rb spec/fixtures/rails.db spec/unit/source/log_parser_spec.rb lib/request_log_analyzer/aggregator/database_inserter.rb spec/fixtures/header_and_footer.log spec/lib/testing_format.rb lib/request_log_analyzer/database.rb spec/unit/file_format/rails_format_spec.rb lib/request_log_analyzer/request.rb lib/request_log_analyzer/output/fixed_width.rb spec/integration/command_line_usage_spec.rb lib/request_log_analyzer/file_format/rack.rb lib/request_log_analyzer/tracker/numeric_value.rb spec/fixtures/test_language_combined.log lib/cli/command_line_arguments.rb lib/request_log_analyzer.rb spec/database.yml spec/unit/request_spec.rb lib/request_log_analyzer/database/base.rb spec/unit/aggregator/database_inserter_spec.rb lib/request_log_analyzer/database/request.rb lib/request_log_analyzer/output/fancy_html.rb lib/cli/database_console_init.rb lib/cli/progressbar.rb lib/request_log_analyzer/database/warning.rb spec/unit/filter/anonymize_filter_spec.rb spec/fixtures/apache_combined.log spec/fixtures/rails_22_cached.log lib/request_log_analyzer/aggregator/summarizer.rb spec/unit/tracker/duration_tracker_spec.rb spec/unit/file_format/common_regular_expressions_spec.rb spec/fixtures/rails_1x.log lib/request_log_analyzer/output.rb spec/unit/file_format/line_definition_spec.rb lib/request_log_analyzer/file_format/mysql.rb spec/unit/file_format/mysql_format_spec.rb request-log-analyzer.gemspec spec/fixtures/apache_common.log lib/request_log_analyzer/file_format/rails.rb Rakefile spec/unit/mailer_spec.rb lib/request_log_analyzer/tracker/hourly_spread.rb spec/unit/aggregator/summarizer_spec.rb spec/unit/tracker/traffic_tracker_spec.rb spec/unit/tracker/numeric_value_tracker_spec.rb lib/request_log_analyzer/tracker/timespan.rb spec/unit/controller/log_processor_spec.rb spec/fixtures/sinatra.log spec/unit/filter/field_filter_spec.rb spec/fixtures/merb_prefixed.log lib/request_log_analyzer/log_processor.rb lib/request_log_analyzer/filter/timespan.rb spec/unit/controller/controller_spec.rb lib/request_log_analyzer/mailer.rb lib/cli/tools.rb spec/fixtures/decompression.tar.gz spec/unit/tracker/timespan_tracker_spec.rb spec/lib/matchers.rb lib/request_log_analyzer/controller.rb spec/unit/tracker/tracker_api_spec.rb lib/request_log_analyzer/source/database_loader.rb spec/fixtures/merb.log LICENSE lib/request_log_analyzer/file_format.rb tasks/request_log_analyzer.rake spec/unit/database/database_spec.rb spec/fixtures/decompression.log.zip spec/fixtures/decompression.tgz bin/request-log-analyzer lib/request_log_analyzer/tracker.rb lib/request_log_analyzer/source.rb spec/fixtures/mysql_slow_query.log lib/request_log_analyzer/source/log_parser.rb lib/request_log_analyzer/aggregator/echo.rb)
|
40
|
+
s.test_files = %w(spec/unit/tracker/hourly_spread_spec.rb spec/unit/file_format/amazon_s3_format_spec.rb spec/unit/database/base_class_spec.rb spec/unit/file_format/rack_format_spec.rb spec/unit/filter/filter_spec.rb spec/unit/database/connection_spec.rb spec/integration/scout_spec.rb spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/format_autodetection_spec.rb spec/unit/filter/timespan_filter_spec.rb spec/unit/file_format/file_format_api_spec.rb spec/integration/mailer_spec.rb spec/unit/tracker/frequency_tracker_spec.rb spec/unit/file_format/apache_format_spec.rb spec/integration/munin_plugins_rails_spec.rb spec/unit/source/log_parser_spec.rb spec/unit/file_format/rails_format_spec.rb spec/integration/command_line_usage_spec.rb spec/unit/request_spec.rb spec/unit/aggregator/database_inserter_spec.rb spec/unit/filter/anonymize_filter_spec.rb spec/unit/tracker/duration_tracker_spec.rb spec/unit/file_format/common_regular_expressions_spec.rb spec/unit/file_format/line_definition_spec.rb spec/unit/file_format/mysql_format_spec.rb spec/unit/mailer_spec.rb spec/unit/aggregator/summarizer_spec.rb spec/unit/tracker/traffic_tracker_spec.rb spec/unit/tracker/numeric_value_tracker_spec.rb spec/unit/controller/log_processor_spec.rb spec/unit/filter/field_filter_spec.rb spec/unit/controller/controller_spec.rb spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/tracker_api_spec.rb spec/unit/database/database_spec.rb)
|
41
41
|
end
|
data/spec/lib/mocks.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe RequestLogAnalyzer::FileFormat::CommonRegularExpressions do
|
4
|
+
|
5
|
+
include RequestLogAnalyzer::FileFormat::CommonRegularExpressions
|
6
|
+
|
7
|
+
describe '.timestamp' do
|
8
|
+
|
9
|
+
it "should parse timestamps with a given format" do
|
10
|
+
timestamp('%Y-%m-%dT%H:%M:%S%z').should =~ '2009-12-03T00:12:37+0100'
|
11
|
+
timestamp('%Y-%m-%dT%H:%M:%S%z').should_not =~ '2009-12-03 00:12:37+0100'
|
12
|
+
timestamp('%Y-%m-%dT%H:%M:%S%z').should_not =~ '2009-12-03T00:12:37'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.ip_address' do
|
17
|
+
|
18
|
+
it "should parse IPv4 addresses" do
|
19
|
+
ip_address.should =~ '127.0.0.1'
|
20
|
+
ip_address.should =~ '255.255.255.255'
|
21
|
+
|
22
|
+
ip_address.should_not =~ '2552.2552.2552.2552'
|
23
|
+
ip_address.should_not =~ '127001'
|
24
|
+
ip_address.should_not =~ ''
|
25
|
+
ip_address.should_not =~ '-'
|
26
|
+
ip_address.should_not =~ 'sub-host.domain.tld'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should pase IPv6 addresses" do
|
30
|
+
ip_address.should =~ '::1'
|
31
|
+
ip_address.should =~ '3ffe:1900:4545:3:200:f8ff:fe21:67cf'
|
32
|
+
ip_address.should =~ '3ffe:1900:4545:3:200:f8ff:127.0.0.1'
|
33
|
+
ip_address.should =~ '::3:200:f8ff:127.0.0.1'
|
34
|
+
|
35
|
+
ip_address.should_not =~ 'qqqq:wwww:eeee:3q:200:wf8ff:fe21:67cf'
|
36
|
+
ip_address.should_not =~ '3ffe44:1900f:454545:3:200:f8ff:ffff:5432'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should allow blank if true is given as parameter" do
|
40
|
+
/^#{ip_address(true)}$/.should =~ ''
|
41
|
+
/^#{ip_address(true)}$/.should_not =~ ' '
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should allow a nil substitute if a string is given as parameter" do
|
45
|
+
/^#{ip_address('-')}$/.should =~ '-'
|
46
|
+
/^#{ip_address('-')}$/.should_not =~ ' -'
|
47
|
+
/^#{ip_address('-')}$/.should_not =~ '--'
|
48
|
+
/^#{ip_address('-')}$/.should_not =~ ''
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -12,8 +12,7 @@ describe RequestLogAnalyzer::FileFormat::Mysql do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should parse a :time line correctly" do
|
15
|
-
line = '# Time: 091112
|
16
|
-
line = '# Time: 091112 8:13:56'
|
15
|
+
line = '# Time: 091112 8:13:56'
|
17
16
|
@file_format.should parse_line(line).as(:time).and_capture(:timestamp => 20091112081356)
|
18
17
|
end
|
19
18
|
|
@@ -23,7 +23,7 @@ describe RequestLogAnalyzer::FileFormat::Rails do
|
|
23
23
|
it "should return a valid language" do
|
24
24
|
@rails.should be_valid
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
it "should at least parse :processing and :completed lines" do
|
28
28
|
@rails.line_definitions.should include(:processing, :completed, :failure)
|
29
29
|
end
|
@@ -52,12 +52,17 @@ describe RequestLogAnalyzer::FileFormat::Rails do
|
|
52
52
|
context context do
|
53
53
|
it "should parse a :processing line correctly" do
|
54
54
|
line = prefix + 'Processing PeopleController#index (for 1.1.1.1 at 2008-08-14 21:16:30) [GET]'
|
55
|
-
@rails.should parse_line(line).as(:processing).and_capture(:controller => 'PeopleController', :action => 'index', :timestamp => 20080814211630, :method => 'GET')
|
55
|
+
@rails.should parse_line(line).as(:processing).and_capture(:controller => 'PeopleController', :action => 'index', :timestamp => 20080814211630, :method => 'GET', :ip => '1.1.1.1')
|
56
56
|
end
|
57
57
|
|
58
|
-
it "should parse a :processing line correctly when it contains ipv6 address" do
|
58
|
+
it "should parse a :processing line correctly when it contains ipv6 localhost address" do
|
59
59
|
line = prefix + 'Processing PeopleController#index (for ::1 at 2008-08-14 21:16:30) [GET]'
|
60
|
-
@rails.should parse_line(line).as(:processing).and_capture(:controller => 'PeopleController', :action => 'index', :timestamp => 20080814211630, :method => 'GET')
|
60
|
+
@rails.should parse_line(line).as(:processing).and_capture(:controller => 'PeopleController', :action => 'index', :timestamp => 20080814211630, :method => 'GET', :ip => '::1')
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should parse a :processing line correctly when it contains ipv6 address" do
|
64
|
+
line = prefix + 'Processing PeopleController#index (for 3ffe:1900:4545:3:200:f8ff:fe21:67cf at 2008-08-14 21:16:30) [GET]'
|
65
|
+
@rails.should parse_line(line).as(:processing).and_capture(:controller => 'PeopleController', :action => 'index', :timestamp => 20080814211630, :method => 'GET', :ip => '3ffe:1900:4545:3:200:f8ff:fe21:67cf')
|
61
66
|
end
|
62
67
|
|
63
68
|
it "should parse a Rails 2.1 style :completed line correctly" do
|
@@ -2,90 +2,10 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
2
|
|
3
3
|
describe RequestLogAnalyzer::Tracker::Duration do
|
4
4
|
|
5
|
-
context 'using a static category' do
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
@tracker = RequestLogAnalyzer::Tracker::Duration.new(:duration => :duration, :category => :category)
|
9
|
-
@tracker.prepare
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should create a category for every request using the category field" do
|
13
|
-
@tracker.update(request(:category => 'a', :duration => 0.2))
|
14
|
-
@tracker.categories.keys.should include('a')
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should register a request as hit in the right category" do
|
18
|
-
@tracker.update(request(:category => 'a', :duration => 0.2))
|
19
|
-
@tracker.update(request(:category => 'b', :duration => 0.3))
|
20
|
-
@tracker.update(request(:category => 'b', :duration => 0.4))
|
21
|
-
|
22
|
-
@tracker.hits('a').should == 1
|
23
|
-
@tracker.hits('b').should == 2
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'using a dynamic category' do
|
28
|
-
before(:each) do
|
29
|
-
@categorizer = Proc.new { |request| request[:duration] > 0.2 ? 'slow' : 'fast' }
|
30
|
-
@tracker = RequestLogAnalyzer::Tracker::Duration.new(:duration => :duration, :category => @categorizer)
|
31
|
-
@tracker.prepare
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should use the categorizer to determine the right category" do
|
35
|
-
@tracker.update(request(:category => 'a', :duration => 0.2))
|
36
|
-
@tracker.update(request(:category => 'b', :duration => 0.3))
|
37
|
-
@tracker.update(request(:category => 'b', :duration => 0.4))
|
38
|
-
|
39
|
-
@tracker.hits('fast').should == 1
|
40
|
-
@tracker.hits('slow').should == 2
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '#update' do
|
45
|
-
|
46
|
-
before(:each) do
|
47
|
-
@tracker = RequestLogAnalyzer::Tracker::Duration.new(:duration => :duration, :category => :category)
|
48
|
-
@tracker.prepare
|
49
|
-
|
50
|
-
@tracker.update(request(:category => 'a', :duration => 0.4))
|
51
|
-
@tracker.update(request(:category => 'a', :duration => 0.2))
|
52
|
-
@tracker.update(request(:category => 'a', :duration => 0.3))
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should sum of the durations for a category correctly" do
|
56
|
-
@tracker.sum('a').should be_close(0.9, 0.000001)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should overall sum of the durations correctly" do
|
60
|
-
@tracker.sum_overall.should be_close(0.9, 0.000001)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should keep track of the minimum and maximum duration" do
|
64
|
-
@tracker.min('a').should == 0.2
|
65
|
-
@tracker.max('a').should == 0.4
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should calculate the mean duration correctly" do
|
69
|
-
@tracker.mean('a').should be_close(0.3, 0.000001)
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should calculate the overall mean duration correctly" do
|
73
|
-
@tracker.mean_overall.should be_close(0.3, 0.000001)
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should calculate the duration variance correctly" do
|
77
|
-
@tracker.variance('a').should be_close(0.01, 0.000001)
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should calculate the duration standard deviation correctly" do
|
81
|
-
@tracker.stddev('a').should be_close(0.1, 0.000001)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
5
|
describe '#report' do
|
86
6
|
|
87
7
|
before(:each) do
|
88
|
-
@tracker = RequestLogAnalyzer::Tracker::Duration.new(:category => :category, :
|
8
|
+
@tracker = RequestLogAnalyzer::Tracker::Duration.new(:category => :category, :value => :duration)
|
89
9
|
@tracker.prepare
|
90
10
|
end
|
91
11
|
|
@@ -112,7 +32,7 @@ describe RequestLogAnalyzer::Tracker::Duration do
|
|
112
32
|
end
|
113
33
|
|
114
34
|
describe '#display_value' do
|
115
|
-
before(:each) { @tracker = RequestLogAnalyzer::Tracker::Duration.new(:category => :category, :
|
35
|
+
before(:each) { @tracker = RequestLogAnalyzer::Tracker::Duration.new(:category => :category, :value => :duration) }
|
116
36
|
|
117
37
|
it "should only display seconds when time < 60" do
|
118
38
|
@tracker.display_value(33.12).should == '33.12s'
|
@@ -125,6 +45,5 @@ describe RequestLogAnalyzer::Tracker::Duration do
|
|
125
45
|
it "should display minutes and wholeseconds when time > 60" do
|
126
46
|
@tracker.display_value(3601.12).should == '1h00m01s'
|
127
47
|
end
|
128
|
-
|
129
48
|
end
|
130
49
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
|
-
describe RequestLogAnalyzer::Tracker::
|
3
|
+
describe RequestLogAnalyzer::Tracker::NumericValue do
|
4
4
|
|
5
5
|
context 'static category' do
|
6
6
|
before(:each) do
|
7
|
-
@tracker = RequestLogAnalyzer::Tracker::
|
7
|
+
@tracker = RequestLogAnalyzer::Tracker::NumericValue.new(:category => :category, :value => :blah)
|
8
8
|
@tracker.prepare
|
9
9
|
end
|
10
10
|
|
@@ -27,7 +27,7 @@ describe RequestLogAnalyzer::Tracker::Count do
|
|
27
27
|
context 'dynamic category' do
|
28
28
|
before(:each) do
|
29
29
|
@categorizer = Proc.new { |request| request[:duration] > 0.2 ? 'slow' : 'fast' }
|
30
|
-
@tracker = RequestLogAnalyzer::Tracker::
|
30
|
+
@tracker = RequestLogAnalyzer::Tracker::NumericValue.new(:category => @categorizer, :value => :blah)
|
31
31
|
@tracker.prepare
|
32
32
|
end
|
33
33
|
|
@@ -40,10 +40,51 @@ describe RequestLogAnalyzer::Tracker::Count do
|
|
40
40
|
@tracker.categories['slow'][:sum].should == 4
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
describe '#update' do
|
45
|
+
|
46
|
+
before(:each) do
|
47
|
+
@tracker = RequestLogAnalyzer::Tracker::NumericValue.new(:value => :duration, :category => :category)
|
48
|
+
@tracker.prepare
|
49
|
+
|
50
|
+
@tracker.update(request(:category => 'a', :duration => 0.4))
|
51
|
+
@tracker.update(request(:category => 'a', :duration => 0.2))
|
52
|
+
@tracker.update(request(:category => 'a', :duration => 0.3))
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should sum of the durations for a category correctly" do
|
56
|
+
@tracker.sum('a').should be_close(0.9, 0.000001)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should overall sum of the durations correctly" do
|
60
|
+
@tracker.sum_overall.should be_close(0.9, 0.000001)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should keep track of the minimum and maximum duration" do
|
64
|
+
@tracker.min('a').should == 0.2
|
65
|
+
@tracker.max('a').should == 0.4
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should calculate the mean duration correctly" do
|
69
|
+
@tracker.mean('a').should be_close(0.3, 0.000001)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should calculate the overall mean duration correctly" do
|
73
|
+
@tracker.mean_overall.should be_close(0.3, 0.000001)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should calculate the duration variance correctly" do
|
77
|
+
@tracker.variance('a').should be_close(0.01, 0.000001)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should calculate the duration standard deviation correctly" do
|
81
|
+
@tracker.stddev('a').should be_close(0.1, 0.000001)
|
82
|
+
end
|
83
|
+
end
|
43
84
|
|
44
85
|
describe '#report' do
|
45
86
|
before(:each) do
|
46
|
-
@tracker = RequestLogAnalyzer::Tracker::
|
87
|
+
@tracker = RequestLogAnalyzer::Tracker::NumericValue.new(:category => :category, :value => :blah)
|
47
88
|
@tracker.prepare
|
48
89
|
end
|
49
90
|
|
@@ -65,20 +106,22 @@ describe RequestLogAnalyzer::Tracker::Count do
|
|
65
106
|
|
66
107
|
describe '#to_yaml_object' do
|
67
108
|
before(:each) do
|
68
|
-
@tracker = RequestLogAnalyzer::Tracker::
|
109
|
+
@tracker = RequestLogAnalyzer::Tracker::NumericValue.new(:category => :category, :value => :blah)
|
69
110
|
@tracker.prepare
|
70
111
|
end
|
71
112
|
|
72
113
|
it "should generate a YAML output" do
|
73
114
|
@tracker.update(request(:category => 'a', :blah => 2))
|
74
115
|
@tracker.update(request(:category => 'b', :blah => 3))
|
75
|
-
@tracker.to_yaml_object.should == {
|
116
|
+
@tracker.to_yaml_object.should == {
|
117
|
+
"a" => { :min => 2, :hits => 1, :max => 2, :mean => 2.0, :sum => 2, :sum_of_squares => 0.0 },
|
118
|
+
"b" => { :min => 3, :hits => 1, :max => 3, :mean => 3.0, :sum => 3, :sum_of_squares => 0.0 }}
|
76
119
|
end
|
77
120
|
end
|
78
121
|
|
79
122
|
describe '#display_value' do
|
80
123
|
before(:each) do
|
81
|
-
@tracker = RequestLogAnalyzer::Tracker::
|
124
|
+
@tracker = RequestLogAnalyzer::Tracker::NumericValue.new(:category => :category, :value => :blah)
|
82
125
|
@tracker.prepare
|
83
126
|
end
|
84
127
|
|
@@ -33,8 +33,9 @@ describe RequestLogAnalyzer::Tracker::Base do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should receive :report when the summary report is being built" do
|
36
|
-
|
37
|
-
|
36
|
+
m = mock_output
|
37
|
+
m.should_receive(:report_tracker).with(@tracker)
|
38
|
+
@summarizer.report(m)
|
38
39
|
end
|
39
40
|
|
40
41
|
it "should receieve :finalize when the summarizer is finalizing" do
|
@@ -2,85 +2,6 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
2
|
|
3
3
|
describe RequestLogAnalyzer::Tracker::Traffic do
|
4
4
|
|
5
|
-
context 'using a field-based category' do
|
6
|
-
before(:each) do
|
7
|
-
@tracker = RequestLogAnalyzer::Tracker::Traffic.new(:traffic => :traffic, :category => :category)
|
8
|
-
@tracker.prepare
|
9
|
-
|
10
|
-
@tracker.update(request(:category => 'a', :traffic => 1))
|
11
|
-
@tracker.update(request(:category => 'b', :traffic => 2))
|
12
|
-
@tracker.update(request(:category => 'b', :traffic => 3))
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should register a request in the right category using the category field" do
|
16
|
-
@tracker.categories.should include('a', 'b')
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should register requests under the correct category" do
|
20
|
-
@tracker.hits('a').should == 1
|
21
|
-
@tracker.hits('b').should == 2
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'using a dynamic category' do
|
26
|
-
|
27
|
-
before(:each) do
|
28
|
-
@categorizer = lambda { |request| request[:traffic] < 2 ? 'few' : 'lots' }
|
29
|
-
@tracker = RequestLogAnalyzer::Tracker::Traffic.new(:traffic => :traffic, :category => @categorizer)
|
30
|
-
@tracker.prepare
|
31
|
-
|
32
|
-
@tracker.update(request(:category => 'a', :traffic => 1))
|
33
|
-
@tracker.update(request(:category => 'b', :traffic => 2))
|
34
|
-
@tracker.update(request(:category => 'b', :traffic => 3))
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should use the categorizer to determine the category" do
|
38
|
-
@tracker.categories.should include('few', 'lots')
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should register requests under the correct category using the categorizer" do
|
42
|
-
@tracker.hits('few').should == 1
|
43
|
-
@tracker.hits('lots').should == 2
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#update' do
|
48
|
-
|
49
|
-
before(:each) do
|
50
|
-
@tracker = RequestLogAnalyzer::Tracker::Traffic.new(:traffic => :traffic, :category => :category)
|
51
|
-
@tracker.prepare
|
52
|
-
|
53
|
-
@tracker.update(request(:category => 'a', :traffic => 2))
|
54
|
-
@tracker.update(request(:category => 'a', :traffic => 1))
|
55
|
-
@tracker.update(request(:category => 'a', :traffic => 3))
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should calculate the total traffic correctly" do
|
59
|
-
@tracker.sum('a').should == 6
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should calculate the traffic variance correctly" do
|
63
|
-
@tracker.variance('a').should == 1.0
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should calculate the traffic standard deviation correctly" do
|
67
|
-
@tracker.stddev('a').should == 1.0
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should calculate the average traffic correctly" do
|
71
|
-
@tracker.mean('a').should == 2.0
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should calculate the overall mean traffic correctly" do
|
75
|
-
@tracker.mean_overall.should == 2.0
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should set min and max traffic correctly" do
|
79
|
-
@tracker.min('a').should == 1
|
80
|
-
@tracker.max('a').should == 3
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
5
|
describe '#report' do
|
85
6
|
before(:each) do
|
86
7
|
@tracker = RequestLogAnalyzer::Tracker::Traffic.new(:category => :category, :traffic => :traffic)
|
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.5.
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willem van Bergen
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-12-
|
13
|
+
date: 2009-12-14 00:00:00 +01:00
|
14
14
|
default_executable: request-log-analyzer
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -69,7 +69,6 @@ files:
|
|
69
69
|
- spec/unit/filter/filter_spec.rb
|
70
70
|
- spec/lib/macros.rb
|
71
71
|
- spec/spec_helper.rb
|
72
|
-
- spec/unit/tracker/count_tracker_spec.rb
|
73
72
|
- spec/fixtures/decompression.log.bz2
|
74
73
|
- spec/unit/database/connection_spec.rb
|
75
74
|
- lib/request_log_analyzer/filter.rb
|
@@ -105,6 +104,7 @@ files:
|
|
105
104
|
- lib/request_log_analyzer/output/fixed_width.rb
|
106
105
|
- spec/integration/command_line_usage_spec.rb
|
107
106
|
- lib/request_log_analyzer/file_format/rack.rb
|
107
|
+
- lib/request_log_analyzer/tracker/numeric_value.rb
|
108
108
|
- spec/fixtures/test_language_combined.log
|
109
109
|
- lib/cli/command_line_arguments.rb
|
110
110
|
- lib/request_log_analyzer.rb
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/request_log_analyzer/database/base.rb
|
114
114
|
- spec/unit/aggregator/database_inserter_spec.rb
|
115
115
|
- lib/request_log_analyzer/database/request.rb
|
116
|
+
- lib/request_log_analyzer/output/fancy_html.rb
|
116
117
|
- lib/cli/database_console_init.rb
|
117
118
|
- lib/cli/progressbar.rb
|
118
119
|
- lib/request_log_analyzer/database/warning.rb
|
@@ -121,8 +122,8 @@ files:
|
|
121
122
|
- spec/fixtures/rails_22_cached.log
|
122
123
|
- lib/request_log_analyzer/aggregator/summarizer.rb
|
123
124
|
- spec/unit/tracker/duration_tracker_spec.rb
|
125
|
+
- spec/unit/file_format/common_regular_expressions_spec.rb
|
124
126
|
- spec/fixtures/rails_1x.log
|
125
|
-
- lib/request_log_analyzer/tracker/count.rb
|
126
127
|
- lib/request_log_analyzer/output.rb
|
127
128
|
- spec/unit/file_format/line_definition_spec.rb
|
128
129
|
- lib/request_log_analyzer/file_format/mysql.rb
|
@@ -135,6 +136,7 @@ files:
|
|
135
136
|
- lib/request_log_analyzer/tracker/hourly_spread.rb
|
136
137
|
- spec/unit/aggregator/summarizer_spec.rb
|
137
138
|
- spec/unit/tracker/traffic_tracker_spec.rb
|
139
|
+
- spec/unit/tracker/numeric_value_tracker_spec.rb
|
138
140
|
- lib/request_log_analyzer/tracker/timespan.rb
|
139
141
|
- spec/unit/controller/log_processor_spec.rb
|
140
142
|
- spec/fixtures/sinatra.log
|
@@ -203,7 +205,6 @@ test_files:
|
|
203
205
|
- spec/unit/database/base_class_spec.rb
|
204
206
|
- spec/unit/file_format/rack_format_spec.rb
|
205
207
|
- spec/unit/filter/filter_spec.rb
|
206
|
-
- spec/unit/tracker/count_tracker_spec.rb
|
207
208
|
- spec/unit/database/connection_spec.rb
|
208
209
|
- spec/integration/scout_spec.rb
|
209
210
|
- spec/unit/file_format/merb_format_spec.rb
|
@@ -221,11 +222,13 @@ test_files:
|
|
221
222
|
- spec/unit/aggregator/database_inserter_spec.rb
|
222
223
|
- spec/unit/filter/anonymize_filter_spec.rb
|
223
224
|
- spec/unit/tracker/duration_tracker_spec.rb
|
225
|
+
- spec/unit/file_format/common_regular_expressions_spec.rb
|
224
226
|
- spec/unit/file_format/line_definition_spec.rb
|
225
227
|
- spec/unit/file_format/mysql_format_spec.rb
|
226
228
|
- spec/unit/mailer_spec.rb
|
227
229
|
- spec/unit/aggregator/summarizer_spec.rb
|
228
230
|
- spec/unit/tracker/traffic_tracker_spec.rb
|
231
|
+
- spec/unit/tracker/numeric_value_tracker_spec.rb
|
229
232
|
- spec/unit/controller/log_processor_spec.rb
|
230
233
|
- spec/unit/filter/field_filter_spec.rb
|
231
234
|
- spec/unit/controller/controller_spec.rb
|