wvanbergen-request-log-analyzer 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/{DESIGN → DESIGN.rdoc} +13 -10
- data/README.rdoc +7 -5
- data/RELEASE_NOTES.rdoc +10 -0
- data/bin/request-log-analyzer +7 -3
- data/lib/cli/tools.rb +2 -2
- data/lib/request_log_analyzer/aggregator/summarizer.rb +51 -2
- data/lib/request_log_analyzer/controller.rb +4 -0
- data/lib/request_log_analyzer/output/fixed_width.rb +36 -1
- data/lib/request_log_analyzer/output/html.rb +20 -2
- data/lib/request_log_analyzer/output.rb +36 -1
- data/lib/request_log_analyzer/request.rb +2 -2
- data/lib/request_log_analyzer/source/database.rb +19 -4
- data/lib/request_log_analyzer/source/log_parser.rb +26 -3
- data/lib/request_log_analyzer/tracker/duration.rb +49 -8
- data/lib/request_log_analyzer/tracker/frequency.rb +30 -7
- data/lib/request_log_analyzer/tracker/hourly_spread.rb +41 -15
- data/lib/request_log_analyzer/tracker/timespan.rb +22 -2
- data/lib/request_log_analyzer/tracker.rb +38 -1
- data/lib/request_log_analyzer.rb +2 -4
- data/spec/fixtures/decompression.log +12 -0
- data/spec/fixtures/decompression.log.bz2 +0 -0
- data/spec/fixtures/decompression.log.gz +0 -0
- data/spec/fixtures/decompression.log.zip +0 -0
- data/spec/fixtures/decompression.tar.gz +0 -0
- data/spec/fixtures/decompression.tgz +0 -0
- data/spec/integration/command_line_usage_spec.rb +14 -14
- data/spec/lib/helper.rb +19 -3
- data/spec/lib/testing_format.rb +1 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/aggregator/summarizer_spec.rb +1 -1
- data/spec/unit/source/log_parser_spec.rb +39 -0
- data/spec/unit/tracker/{tracker_api_test.rb → tracker_api_spec.rb} +7 -1
- data/tasks/github-gem.rake +1 -2
- data/tasks/request_log_analyzer.rake +23 -7
- metadata +12 -5
- data/HACKING +0 -7
data/spec/lib/helper.rb
CHANGED
@@ -2,15 +2,17 @@ module RequestLogAnalyzer::Spec::Helper
|
|
2
2
|
|
3
3
|
include RequestLogAnalyzer::Spec::Mocks
|
4
4
|
|
5
|
-
|
5
|
+
# Create or return a new TestingFormat
|
6
6
|
def testing_format
|
7
7
|
@testing_format ||= TestingFormat.new
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
# Load a log file from the fixture folder
|
11
|
+
def log_fixture(name, extention = "log")
|
12
|
+
File.dirname(__FILE__) + "/../fixtures/#{name}.#{extention}"
|
12
13
|
end
|
13
14
|
|
15
|
+
# Request loopback
|
14
16
|
def request(fields, format = testing_format)
|
15
17
|
if fields.kind_of?(Array)
|
16
18
|
format.request(*fields)
|
@@ -19,6 +21,8 @@ module RequestLogAnalyzer::Spec::Helper
|
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
24
|
+
# Run a specific command
|
25
|
+
# Used to call request-log-analyzer through binary
|
22
26
|
def run(arguments)
|
23
27
|
binary = "#{File.dirname(__FILE__)}/../../bin/request-log-analyzer"
|
24
28
|
arguments = arguments.join(' ') if arguments.kind_of?(Array)
|
@@ -30,4 +34,16 @@ module RequestLogAnalyzer::Spec::Helper
|
|
30
34
|
$?.exitstatus.should == 0
|
31
35
|
output
|
32
36
|
end
|
37
|
+
|
38
|
+
# Cleanup all temporary files generated by specs
|
39
|
+
def cleanup_temp_files!
|
40
|
+
Dir["#{File.dirname(__FILE__)}/../../tmp/spec.*tmp"].each do |file|
|
41
|
+
File.unlink(file)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Return a filename that can be used as temporary file in specs
|
46
|
+
def temp_output_file(file_type)
|
47
|
+
"#{File.dirname(__FILE__)}/../../tmp/spec.#{file_type}.tmp"
|
48
|
+
end
|
33
49
|
end
|
data/spec/lib/testing_format.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -64,4 +64,43 @@ describe RequestLogAnalyzer::Source::LogParser, :warnings do
|
|
64
64
|
@log_parser.should_not_receive(:handle_request)
|
65
65
|
@log_parser.parse_file(log_fixture(:test_order))
|
66
66
|
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe RequestLogAnalyzer::Source::LogParser, :decompression do
|
70
|
+
include RequestLogAnalyzer::Spec::Helper
|
71
|
+
|
72
|
+
before(:each) do
|
73
|
+
@log_parser = RequestLogAnalyzer::Source::LogParser.new(RequestLogAnalyzer::FileFormat::Rails.new)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should parse a rails gzipped log file" do
|
77
|
+
@log_parser.should_receive(:handle_request).once
|
78
|
+
@log_parser.parse_file(log_fixture(:decompression, "log.gz"))
|
79
|
+
@log_parser.parsed_lines.should > 0
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should parse a rails tar gzipped log folder" do
|
83
|
+
@log_parser.should_receive(:handle_request).twice
|
84
|
+
@log_parser.parse_file(log_fixture(:decompression, "tar.gz"))
|
85
|
+
@log_parser.parsed_lines.should > 1
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should parse a rails tar gzipped log folder" do
|
89
|
+
@log_parser.should_receive(:handle_request).twice
|
90
|
+
@log_parser.parse_file(log_fixture(:decompression, "tgz"))
|
91
|
+
@log_parser.parsed_lines.should > 1
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should parse a rails bz2 zipped log file" do
|
95
|
+
@log_parser.should_receive(:handle_request).once
|
96
|
+
@log_parser.parse_file(log_fixture(:decompression, "log.bz2"))
|
97
|
+
@log_parser.parsed_lines.should > 0
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should parse a rails zipped log file" do
|
101
|
+
@log_parser.should_receive(:handle_request).once
|
102
|
+
@log_parser.parse_file(log_fixture(:decompression, "log.zip"))
|
103
|
+
@log_parser.parsed_lines.should > 0
|
104
|
+
end
|
105
|
+
|
67
106
|
end
|
@@ -10,7 +10,7 @@ describe RequestLogAnalyzer::Tracker::Base, "API test" do
|
|
10
10
|
@summarizer = RequestLogAnalyzer::Aggregator::Summarizer.new(mock_source)
|
11
11
|
@summarizer.trackers << @tracker
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
it "should receive :prepare when the summarizer is preparing" do
|
15
15
|
@tracker.should_receive(:prepare).once
|
16
16
|
@summarizer.prepare
|
@@ -42,4 +42,10 @@ describe RequestLogAnalyzer::Tracker::Base, "API test" do
|
|
42
42
|
@summarizer.report(mock_output)
|
43
43
|
end
|
44
44
|
|
45
|
+
it "should receive :to_yaml object when finalizing" do
|
46
|
+
@summarizer.options[:dump] = temp_output_file(:dump)
|
47
|
+
@tracker.should_receive(:to_yaml_object).once
|
48
|
+
@summarizer.to_yaml
|
49
|
+
end
|
50
|
+
|
45
51
|
end
|
data/tasks/github-gem.rake
CHANGED
@@ -1,10 +1,26 @@
|
|
1
|
-
namespace :
|
2
|
-
desc "Analyze the Rails log file using the request-log-analyzer gem."
|
3
|
-
|
1
|
+
namespace :rla do
|
2
|
+
desc "Analyze the Rails log file using the request-log-analyzer gem."
|
3
|
+
task :report => :environment do
|
4
|
+
puts "Analyzing the Rails log file using the request-log-analyzer gem."
|
5
|
+
puts " Environment: #{RAILS_ENV}"
|
6
|
+
puts " Logfile: #{Rails.configuration.log_path}"
|
7
|
+
puts ""
|
8
|
+
IO.popen("request-log-analyzer #{Rails.configuration.log_path}") { |io| $stdout << io.read }
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
namespace :report do
|
13
|
+
desc "Analyze the Rails log file using the request-log-analyzer gem and output an HTML file."
|
14
|
+
task :html => :environment do
|
15
|
+
output_file = Rails.configuration.log_path + ".html"
|
16
|
+
|
4
17
|
puts "Analyzing the Rails log file using the request-log-analyzer gem."
|
5
|
-
puts "Environment: #{RAILS_ENV}"
|
6
|
-
puts "Logfile: #{Rails.configuration.log_path}"
|
18
|
+
puts " Environment: #{RAILS_ENV}"
|
19
|
+
puts " Logfile: #{Rails.configuration.log_path}"
|
20
|
+
puts " Output: #{output_file}"
|
7
21
|
puts ""
|
8
|
-
|
22
|
+
IO.popen("request-log-analyzer #{Rails.configuration.log_path} --output HTML --file #{output_file}") { |io| $stdout << io.read }
|
23
|
+
end
|
9
24
|
end
|
10
|
-
|
25
|
+
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wvanbergen-request-log-analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
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-
|
13
|
+
date: 2009-07-15 00:00:00 -07:00
|
14
14
|
default_executable: request-log-analyzer
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -23,10 +23,10 @@ extensions: []
|
|
23
23
|
extra_rdoc_files:
|
24
24
|
- README.rdoc
|
25
25
|
files:
|
26
|
-
- DESIGN
|
27
|
-
- HACKING
|
26
|
+
- DESIGN.rdoc
|
28
27
|
- LICENSE
|
29
28
|
- README.rdoc
|
29
|
+
- RELEASE_NOTES.rdoc
|
30
30
|
- Rakefile
|
31
31
|
- bin
|
32
32
|
- bin/request-log-analyzer
|
@@ -72,6 +72,12 @@ files:
|
|
72
72
|
- lib/request_log_analyzer/tracker/timespan.rb
|
73
73
|
- spec
|
74
74
|
- spec/fixtures
|
75
|
+
- spec/fixtures/decompression.log
|
76
|
+
- spec/fixtures/decompression.log.bz2
|
77
|
+
- spec/fixtures/decompression.log.gz
|
78
|
+
- spec/fixtures/decompression.log.zip
|
79
|
+
- spec/fixtures/decompression.tar.gz
|
80
|
+
- spec/fixtures/decompression.tgz
|
75
81
|
- spec/fixtures/merb.log
|
76
82
|
- spec/fixtures/multiple_files_1.log
|
77
83
|
- spec/fixtures/multiple_files_2.log
|
@@ -114,7 +120,7 @@ files:
|
|
114
120
|
- spec/unit/tracker/frequency_tracker_spec.rb
|
115
121
|
- spec/unit/tracker/hourly_spread_spec.rb
|
116
122
|
- spec/unit/tracker/timespan_tracker_spec.rb
|
117
|
-
- spec/unit/tracker/
|
123
|
+
- spec/unit/tracker/tracker_api_spec.rb
|
118
124
|
- tasks
|
119
125
|
- tasks/github-gem.rake
|
120
126
|
- tasks/request_log_analyzer.rake
|
@@ -169,3 +175,4 @@ test_files:
|
|
169
175
|
- spec/unit/tracker/frequency_tracker_spec.rb
|
170
176
|
- spec/unit/tracker/hourly_spread_spec.rb
|
171
177
|
- spec/unit/tracker/timespan_tracker_spec.rb
|
178
|
+
- spec/unit/tracker/tracker_api_spec.rb
|
data/HACKING
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
HACKING on request-log-analyzer
|
2
|
-
-------------------------------
|
3
|
-
|
4
|
-
- See DESIGN for the basic internal design of request-log-analyzer
|
5
|
-
- See http://wiki.github.com/wvanbergen/request-log-analyzer/development for
|
6
|
-
more information about developing
|
7
|
-
- Contact me at my GitHub account for any questions: http://github.com/wvanbergen
|