oink 0.9.3 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,33 @@
1
+ === 0.10.0 / 2013-01-03
2
+
3
+ * Additional summary information (average, max, min, total, number requests) (bjpirt)
4
+
5
+ === 0.9.3 / 2011-07-08
6
+
7
+ * (BUGFIX) Correctly log a controller action that lives in a module (wagner)
8
+ * (BUGFIX) Log fix for Rails 2.3.x (yar)
9
+
10
+ === 0.9.2 / 2011-04-05
11
+
12
+ * More configurable middleware (noahd1, edsinclair)
13
+ * Update license (still MIT) (noahd1)
14
+
15
+ === 0.9.1 / 2011-03-23
16
+
17
+ * Remove unnecessary dependency (noahd1)
18
+
19
+ === 0.9.0 / 2011-03-23
20
+
21
+ * Introduce middleware and deprecate controller modules (noahd1, edsinclair)
22
+
23
+ === 0.1.2 / 2010-10-08
24
+
25
+ * Prefer statm to smaps (jordan-brough)
26
+
27
+ === 0.1.1 / 2010-09-30
28
+
29
+ * Dependency fixes
30
+
1
31
  === 0.1.0 / 2009-02-09
2
32
 
3
33
  * 1st release
@@ -30,7 +30,7 @@ When used as a gem, this is automatically brought in as a dependency.
30
30
 
31
31
  Add oink to your Gemfile
32
32
 
33
- gem "oink"
33
+ gem "oink"
34
34
 
35
35
  In most rails environments this is sufficient and oink will be required for you via bundler.
36
36
  If not, add a require statement "require 'oink'" in your app.
@@ -115,6 +115,16 @@ e.g. To find all actions which increase the heap size more than 75 MB, where log
115
115
  1, PublicPagesController#join
116
116
  1, CommentsController#create
117
117
 
118
+ Aggregated Totals:
119
+ Action Max Mean Min Total Number of requests
120
+ SportsController#show 101560 19754 4 5590540 283
121
+ CommentsController#create 8344 701 4 253324 361
122
+ ColorSchemesController#show 10124 739 4 68756 93
123
+ PublicPagesController#join 9004 1346 8 51172 38
124
+ DashboardsController#show 13696 2047 8 45036 22
125
+ SessionsController#create 9220 528 8 17448 33
126
+ GroupsController#show 10748 1314 8 15776 12
127
+
118
128
  e.g. In verbose mode, oink will print out all the log information from your logs about the actions which exceeded the threshold specified
119
129
 
120
130
  $ oink --format verbose --threshold=75 /tmp/logs/*
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- require "rake/gempackagetask"
1
+ require "rubygems/package_task"
2
2
  require "rake/clean"
3
3
  require "rspec/core/rake_task"
4
4
 
@@ -6,7 +6,7 @@ begin
6
6
  require 'jeweler'
7
7
  Jeweler::Tasks.new do |s|
8
8
  s.name = "oink"
9
- s.version = "0.9.3"
9
+ s.version = "0.10.0"
10
10
  s.author = "Noah Davis"
11
11
  s.email = "noahd1" + "@" + "yahoo.com"
12
12
  s.homepage = "http://github.com/noahd1/oink"
@@ -8,31 +8,39 @@ module Oink
8
8
  @oink_extended_active_record = true
9
9
  end
10
10
 
11
+ def self.extend_active_record!
12
+ ::ActiveRecord::Base.class_eval do
13
+ include Instrumentation::ActiveRecord
14
+ end
15
+ end
16
+
11
17
  module Instrumentation
12
18
  module ActiveRecord
13
19
 
14
20
  def self.included(klass)
15
21
  klass.class_eval do
16
22
 
17
- @@instantiated = {}
18
- @@total = nil
19
-
20
23
  def self.reset_instance_type_count
21
- @@instantiated = {}
22
- @@total = nil
24
+ self.instantiated_hash = {}
25
+ Thread.current['oink.activerecord.instantiations_count'] = nil
23
26
  end
24
27
 
25
28
  def self.increment_instance_type_count
26
- @@instantiated[base_class.name] ||= 0
27
- @@instantiated[base_class.name] += 1
29
+ self.instantiated_hash ||= {}
30
+ self.instantiated_hash[base_class.name] ||= 0
31
+ self.instantiated_hash[base_class.name] += 1
28
32
  end
29
33
 
30
34
  def self.instantiated_hash
31
- @@instantiated
35
+ Thread.current['oink.activerecord.instantiations']
36
+ end
37
+
38
+ def self.instantiated_hash=(hsh)
39
+ Thread.current['oink.activerecord.instantiations'] = hsh
32
40
  end
33
41
 
34
42
  def self.total_objects_instantiated
35
- @@total ||= @@instantiated.values.sum
43
+ Thread.current['oink.activerecord.instantiations_count'] ||= self.instantiated_hash.values.sum
36
44
  end
37
45
 
38
46
  unless Oink.extended_active_record?
@@ -72,7 +72,8 @@ module Oink
72
72
  class SmapsMemorySnapshot
73
73
  def memory
74
74
  proc_file = File.new("/proc/#{$$}/smaps")
75
- proc_file.map do |line|
75
+ lines = proc_file.lines
76
+ lines.map do |line|
76
77
  size = line[/Size: *(\d+)/, 1] and size.to_i
77
78
  end.compact.sum
78
79
  end
@@ -116,4 +117,4 @@ module Oink
116
117
 
117
118
  end
118
119
 
119
- end
120
+ end
@@ -10,7 +10,7 @@ module Oink
10
10
  @logger = options[:logger] || Hodel3000CompliantLogger.new("log/oink.log")
11
11
  @instruments = options[:instruments] ? Array(options[:instruments]) : [:memory, :activerecord]
12
12
 
13
- ActiveRecord::Base.send(:include, Oink::Instrumentation::ActiveRecord) if @instruments.include?(:activerecord)
13
+ Oink.extend_active_record! if @instruments.include?(:activerecord)
14
14
  end
15
15
 
16
16
  def call(env)
@@ -13,6 +13,7 @@ module Oink
13
13
 
14
14
  @pids = {}
15
15
  @bad_actions = {}
16
+ @bad_actions_averaged = {}
16
17
  @bad_requests = PriorityQueue.new(10)
17
18
  end
18
19
 
@@ -32,6 +33,25 @@ module Oink
32
33
  @bad_actions.sort{|a,b| b[1]<=>a[1]}.each { |elem|
33
34
  output.puts "#{elem[1]}, #{elem[0]}"
34
35
  }
36
+ output.puts "\nAggregated Totals:\n"
37
+ if @bad_actions_averaged.length > 0
38
+ action_stats = @bad_actions_averaged.map { |action,values|
39
+ total = values.inject(0){ |sum,x| sum+x }
40
+ {
41
+ :action => action,
42
+ :total => total,
43
+ :mean => total/values.length,
44
+ :max => values.max,
45
+ :min => values.min,
46
+ :count => values.length,
47
+ }
48
+ }
49
+ action_width = @bad_actions_averaged.keys.map{|k| k.length}.max
50
+ output.puts "#{'Action'.ljust(action_width)}\tMax\tMean\tMin\tTotal\tNumber of requests"
51
+ action_stats.sort{|a,b| b[:total]<=>a[:total]}.each do |action_stat|
52
+ output.puts "#{action_stat[:action].ljust(action_width)}\t#{action_stat[:max]}\t#{action_stat[:mean]}\t#{action_stat[:min]}\t#{action_stat[:total]}\t#{action_stat[:count]}"
53
+ end
54
+ end
35
55
  end
36
56
  end
37
57
  end
@@ -52,6 +52,8 @@ module Oink
52
52
  @pids[pid][:buffer].each { |b| output.puts b }
53
53
  output.puts "---------------------------------------------------------------------"
54
54
  end
55
+ @bad_actions_averaged[@pids[pid][:action]] ||= []
56
+ @bad_actions_averaged[@pids[pid][:action]] << memory_diff
55
57
  end
56
58
  end
57
59
 
@@ -68,4 +70,4 @@ module Oink
68
70
  end
69
71
  end
70
72
  end
71
- end
73
+ end
metadata CHANGED
@@ -1,144 +1,168 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: oink
3
- version: !ruby/object:Gem::Version
4
- hash: 61
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.10.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 9
9
- - 3
10
- version: 0.9.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Noah Davis
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-07-08 00:00:00 -04:00
19
- default_executable: oink
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- type: :runtime
23
- version_requirements: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
32
- requirement: *id001
33
- prerelease: false
12
+ date: 2013-01-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
34
15
  name: hodel_3000_compliant_logger
35
- - !ruby/object:Gem::Dependency
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
36
22
  type: :runtime
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
46
- requirement: *id002
47
23
  prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
48
31
  name: activerecord
49
- - !ruby/object:Gem::Dependency
50
- type: :development
51
- version_requirements: &id003 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 3
57
- segments:
58
- - 0
59
- version: "0"
60
- requirement: *id003
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
61
39
  prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
62
47
  name: jeweler
63
- - !ruby/object:Gem::Dependency
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
64
54
  type: :development
65
- version_requirements: &id004 !ruby/object:Gem::Requirement
66
- none: false
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- hash: 3
71
- segments:
72
- - 0
73
- version: "0"
74
- requirement: *id004
75
55
  prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
76
63
  name: rspec
77
- - !ruby/object:Gem::Dependency
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
78
70
  type: :development
79
- version_requirements: &id005 !ruby/object:Gem::Requirement
80
- none: false
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- hash: 3
85
- segments:
86
- - 0
87
- version: "0"
88
- requirement: *id005
89
71
  prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
90
79
  name: sqlite3
91
- - !ruby/object:Gem::Dependency
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
92
86
  type: :development
93
- version_requirements: &id006 !ruby/object:Gem::Requirement
94
- none: false
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- hash: 3
99
- segments:
100
- - 0
101
- version: "0"
102
- requirement: *id006
103
87
  prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
104
95
  name: rack-test
105
- - !ruby/object:Gem::Dependency
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
106
102
  type: :development
107
- version_requirements: &id007 !ruby/object:Gem::Requirement
108
- none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- hash: 3
113
- segments:
114
- - 0
115
- version: "0"
116
- requirement: *id007
117
103
  prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
118
111
  name: rake
119
- - !ruby/object:Gem::Dependency
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
120
118
  type: :development
121
- version_requirements: &id008 !ruby/object:Gem::Requirement
122
- none: false
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- hash: 3
127
- segments:
128
- - 0
129
- version: "0"
130
- requirement: *id008
131
119
  prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
132
127
  name: ruby-debug
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: debugger
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
133
158
  description: Log parser to identify actions which significantly increase VM heap size
134
159
  email: noahd1@yahoo.com
135
- executables:
160
+ executables:
136
161
  - oink
137
162
  extensions: []
138
-
139
- extra_rdoc_files:
163
+ extra_rdoc_files:
140
164
  - README.rdoc
141
- files:
165
+ files:
142
166
  - History.txt
143
167
  - MIT-LICENSE
144
168
  - README.rdoc
@@ -161,66 +185,31 @@ files:
161
185
  - lib/oink/reports/priority_queue.rb
162
186
  - lib/oink/reports/request.rb
163
187
  - lib/oink/utils/hash_utils.rb
164
- - spec/fakes/fake_application_controller.rb
165
- - spec/fakes/psuedo_output.rb
166
- - spec/helpers/database.rb
167
- - spec/oink/instrumentation/instance_type_counter_spec.rb
168
- - spec/oink/instrumentation/memory_snapshot_spec.rb
169
- - spec/oink/middleware_configuration_spec.rb
170
- - spec/oink/middleware_spec.rb
171
- - spec/oink/rails/instance_type_counter_spec.rb
172
- - spec/oink/rails/memory_usage_logger_spec.rb
173
- - spec/oink/reports/active_record_instantiation_report_spec.rb
174
- - spec/oink/reports/memory_usage_report_spec.rb
175
- - spec/oink/reports/oinked_request_spec.rb
176
- - spec/oink/reports/priority_queue_spec.rb
177
- - spec/spec_helper.rb
178
- has_rdoc: true
179
188
  homepage: http://github.com/noahd1/oink
180
189
  licenses: []
181
-
182
190
  post_install_message:
183
191
  rdoc_options: []
184
-
185
- require_paths:
192
+ require_paths:
186
193
  - lib
187
- required_ruby_version: !ruby/object:Gem::Requirement
194
+ required_ruby_version: !ruby/object:Gem::Requirement
188
195
  none: false
189
- requirements:
190
- - - ">="
191
- - !ruby/object:Gem::Version
192
- hash: 3
193
- segments:
196
+ requirements:
197
+ - - ! '>='
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ segments:
194
201
  - 0
195
- version: "0"
196
- required_rubygems_version: !ruby/object:Gem::Requirement
202
+ hash: 1899106649143514208
203
+ required_rubygems_version: !ruby/object:Gem::Requirement
197
204
  none: false
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- hash: 3
202
- segments:
203
- - 0
204
- version: "0"
205
+ requirements:
206
+ - - ! '>='
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
205
209
  requirements: []
206
-
207
210
  rubyforge_project:
208
- rubygems_version: 1.4.2
211
+ rubygems_version: 1.8.24
209
212
  signing_key:
210
213
  specification_version: 3
211
214
  summary: Log parser to identify actions which significantly increase VM heap size
212
- test_files:
213
- - spec/fakes/fake_application_controller.rb
214
- - spec/fakes/psuedo_output.rb
215
- - spec/helpers/database.rb
216
- - spec/oink/instrumentation/instance_type_counter_spec.rb
217
- - spec/oink/instrumentation/memory_snapshot_spec.rb
218
- - spec/oink/middleware_configuration_spec.rb
219
- - spec/oink/middleware_spec.rb
220
- - spec/oink/rails/instance_type_counter_spec.rb
221
- - spec/oink/rails/memory_usage_logger_spec.rb
222
- - spec/oink/reports/active_record_instantiation_report_spec.rb
223
- - spec/oink/reports/memory_usage_report_spec.rb
224
- - spec/oink/reports/oinked_request_spec.rb
225
- - spec/oink/reports/priority_queue_spec.rb
226
- - spec/spec_helper.rb
215
+ test_files: []