request-log-analyzer 1.9.8 → 1.9.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,7 @@ module RequestLogAnalyzer
13
13
 
14
14
  # The current version of request-log-analyzer.
15
15
  # Do not change the value by hand; it will be updated automatically by the gem release script.
16
- VERSION = "1.9.8"
16
+ VERSION = "1.9.9"
17
17
 
18
18
 
19
19
  autoload :Controller, 'request_log_analyzer/controller'
@@ -26,6 +26,12 @@ class RequestLogAnalyzer::FileFormat::Oink < RequestLogAnalyzer::FileFormat::Rai
26
26
  line.capture(:pid).as(:integer)
27
27
  line.capture(:memory).as(:traffic)
28
28
  end
29
+
30
+ line_definition :instance_type_counter do |line|
31
+ line.regexp = /\[(\d+)\]: Instantiation Breakdown: (.*)$/
32
+ line.capture(:pid).as(:integer)
33
+ line.capture(:instance_counts).as(:pipe_separated_counts)
34
+ end
29
35
 
30
36
  report(:append) do |analyze|
31
37
  analyze.traffic :memory_diff, :category => REQUEST_CATEGORIZER, :title => "Largest Memory Increases", :line_type => :memory_usage
@@ -35,7 +41,7 @@ class RequestLogAnalyzer::FileFormat::Oink < RequestLogAnalyzer::FileFormat::Rai
35
41
  def pids
36
42
  @pids ||= {}
37
43
  end
38
-
44
+
39
45
  class Request < RequestLogAnalyzer::FileFormat::Rails::Request
40
46
  # Overrides the #validate method to handle PID updating.
41
47
  def validate
@@ -74,5 +80,17 @@ class RequestLogAnalyzer::FileFormat::Oink < RequestLogAnalyzer::FileFormat::Rai
74
80
  end # if mem_line
75
81
  return true
76
82
  end # def update_pids
83
+
84
+ def convert_pipe_separated_counts(value, capture_definition)
85
+ count_strings = value.split(' | ')
86
+ count_arrays = count_strings.map do |count_string|
87
+ if count_string =~ /^(\w+): (\d+)/
88
+ [$1, $2.to_i]
89
+ end
90
+ end
91
+
92
+ Hash[count_arrays]
93
+ end
94
+
77
95
  end # class Request
78
- end
96
+ end
@@ -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.9.8"
6
- s.date = "2010-12-01"
5
+ s.version = "1.9.9"
6
+ s.date = "2010-12-17"
7
7
 
8
8
  s.rubyforge_project = 'r-l-a'
9
9
 
@@ -30,6 +30,13 @@ describe RequestLogAnalyzer::FileFormat::Oink do
30
30
  line = 'Aug 14 21:16:30 derek rails[67783]: Processing PeopleController#index (for 1.1.1.1 at 2008-08-14 21:16:30) [GET]'
31
31
  @oink.should parse_line(line).as(:processing).and_capture(:pid => 67783, :controller => 'PeopleController', :action => 'index', :timestamp => 20080814211630, :method => 'GET', :ip => '1.1.1.1')
32
32
  end
33
+
34
+ it "should parse a :instance_type_counter correctly" do
35
+
36
+ line = "Dec 13 12:00:44 storenvy rails[26364]: Instantiation Breakdown: Total: 732 | User: 376 | Post: 323 | Comment: 32 | Blog: 1"
37
+
38
+ @oink.should parse_line(line).as(:instance_type_counter).and_capture(:pid => 26364, :instance_counts => {'Total' => 732, 'User' => 376, 'Post' => 323, 'Comment' => 32, 'Blog' => 1})
39
+ end
33
40
  end
34
41
 
35
42
  describe '#parse_io' do
@@ -54,11 +54,11 @@ describe RequestLogAnalyzer::Tracker::NumericValue do
54
54
  end
55
55
 
56
56
  it "should sum of the durations for a category correctly" do
57
- @tracker.sum('a').should be_close(0.9, 0.000001)
57
+ @tracker.sum('a').should be_within(0.000001).of(0.9)
58
58
  end
59
59
 
60
60
  it "should overall sum of the durations correctly" do
61
- @tracker.sum_overall.should be_close(0.9, 0.000001)
61
+ @tracker.sum_overall.should be_within(0.000001).of(0.9)
62
62
  end
63
63
 
64
64
  it "should keep track of the minimum and maximum duration" do
@@ -67,19 +67,19 @@ describe RequestLogAnalyzer::Tracker::NumericValue do
67
67
  end
68
68
 
69
69
  it "should calculate the mean duration correctly" do
70
- @tracker.mean('a').should be_close(0.3, 0.000001)
70
+ @tracker.mean('a').should be_within(0.000001).of(0.3)
71
71
  end
72
72
 
73
73
  it "should calculate the overall mean duration correctly" do
74
- @tracker.mean_overall.should be_close(0.3, 0.000001)
74
+ @tracker.mean_overall.should be_within(0.000001).of(0.3)
75
75
  end
76
76
 
77
77
  it "should calculate the duration variance correctly" do
78
- @tracker.variance('a').should be_close(0.01, 0.000001)
78
+ @tracker.variance('a').should be_within(0.000001).of(0.01)
79
79
  end
80
80
 
81
81
  it "should calculate the duration standard deviation correctly" do
82
- @tracker.stddev('a').should be_close(0.1, 0.000001)
82
+ @tracker.stddev('a').should be_within(0.000001).of(0.1)
83
83
  end
84
84
 
85
85
  it "should calculate the bucket spread correctly" do
@@ -92,12 +92,12 @@ describe RequestLogAnalyzer::Tracker::NumericValue do
92
92
  @tracker.update(request(:category => 'a', :duration => 0.3))
93
93
  # 0.2, 0.3 and 0.4 are already there, so, 10 values in total
94
94
 
95
- @tracker.median('a').should be_close(0.3, 0.01)
95
+ @tracker.median('a').should be_within(0.01).of(0.3)
96
96
 
97
- @tracker.percentile_interval('a', 80).begin.should be_close(0.3, 0.01)
98
- @tracker.percentile_interval('a', 80).end.should be_close(0.3, 0.01)
99
- @tracker.percentile_interval('a', 90).begin.should be_close(0.2, 0.01)
100
- @tracker.percentile_interval('a', 90).end.should be_close(0.4, 0.01)
97
+ @tracker.percentile_interval('a', 80).begin.should be_within(0.01).of(0.3)
98
+ @tracker.percentile_interval('a', 80).end.should be_within(0.01).of(0.3)
99
+ @tracker.percentile_interval('a', 90).begin.should be_within(0.01).of(0.2)
100
+ @tracker.percentile_interval('a', 90).end.should be_within(0.01).of(0.4)
101
101
  end
102
102
  end
103
103
 
@@ -135,9 +135,10 @@ describe RequestLogAnalyzer::Tracker::NumericValue do
135
135
  @tracker.to_yaml_object.keys.should =~ ['a', 'b']
136
136
 
137
137
  @tracker.to_yaml_object['a'].should include(:min => 2, :hits => 1, :max => 2, :mean => 2.0, :sum => 2, :sum_of_squares => 0.0)
138
- @tracker.to_yaml_object['a'][:interval_95_percent].member?(2).should be_true
138
+ @tracker.to_yaml_object['a'][:interval_95_percent].should be_member(2)
139
+
139
140
  @tracker.to_yaml_object['b'].should include(:min => 3, :hits => 1, :max => 3, :mean => 3.0, :sum => 3, :sum_of_squares => 0.0)
140
- @tracker.to_yaml_object['b'][:interval_95_percent].should be_true
141
+ @tracker.to_yaml_object['b'][:interval_95_percent].should be_member(3)
141
142
  end
142
143
  end
143
144
 
@@ -220,7 +220,7 @@ module GithubGem
220
220
 
221
221
  def check_version_task
222
222
  raise "#{ENV['VERSION']} is not a valid version number!" if ENV['VERSION'] && !Gem::Version.correct?(ENV['VERSION'])
223
- proposed_version = Gem::Version.new(ENV['VERSION'].dup || gemspec.version)
223
+ proposed_version = Gem::Version.new((ENV['VERSION'] || gemspec.version).dup)
224
224
  raise "This version (#{proposed_version}) is not higher than the highest tagged version (#{newest_version})" if newest_version >= proposed_version
225
225
  end
226
226
 
@@ -339,22 +339,26 @@ module GithubGem
339
339
 
340
340
  # Updates the tasks file using the latest file found on Github
341
341
  def update_tasks_task
342
- require 'net/http'
343
-
344
- server = 'github.com'
345
- path = '/wvanbergen/github-gem/raw/master/tasks/github-gem.rake'
342
+ require 'net/https'
343
+ require 'uri'
344
+
345
+ uri = URI.parse('https://github.com/wvanbergen/github-gem/raw/master/tasks/github-gem.rake')
346
+ http = Net::HTTP.new(uri.host, uri.port)
347
+ http.use_ssl = true
348
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
349
+ response = http.request(Net::HTTP::Get.new(uri.path))
346
350
 
347
- Net::HTTP.start(server) do |http|
348
- response = http.get(path)
351
+ if Net::HTTPSuccess === response
349
352
  open(__FILE__, "w") { |file| file.write(response.body) }
350
- end
351
-
352
- relative_file = File.expand_path(__FILE__).sub(%r[^#{@root_dir}/], '')
353
- if `#{git} ls-files -m #{relative_file}`.split("\n").any?
354
- sh git, 'add', relative_file
355
- sh git, 'commit', '-m', "Updated to latest gem release management tasks."
353
+ relative_file = File.expand_path(__FILE__).sub(%r[^#{@root_dir}/], '')
354
+ if `#{git} ls-files -m #{relative_file}`.split("\n").any?
355
+ sh git, 'add', relative_file
356
+ sh git, 'commit', '-m', "Updated to latest gem release management tasks."
357
+ else
358
+ puts "Release managament tasks already are at the latest version."
359
+ end
356
360
  else
357
- puts "Release managament tasks already are at the latest version."
361
+ raise "Download failed with HTTP status #{response.code}!"
358
362
  end
359
363
  end
360
364
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 9
8
- - 8
9
- version: 1.9.8
8
+ - 9
9
+ version: 1.9.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Willem van Bergen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-01 00:00:00 -05:00
18
+ date: 2010-12-17 00:00:00 -05:00
19
19
  default_executable: request-log-analyzer
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency