Class: Insight::ActiveRecordPanel
- Inherits:
-
Panel
- Object
- Panel
- Insight::ActiveRecordPanel
show all
- Defined in:
- lib/insight/panels/active_record_panel.rb
Instance Attribute Summary
Attributes inherited from Panel
#request
Instance Method Summary
collapse
Methods inherited from Panel
#after, #before, #call, current_panel_file, excluded, file_index, from_file, #has_content?, inherited, #panel_app, panel_exclusion, panel_mappings, #render
#before_detect, #probe
Methods included from Logging
logger
#key_sql_template, #retrieve, #store, #table_length, #table_setup
Methods included from Render
#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params
Constructor Details
Returns a new instance of ActiveRecordPanel.
3
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/insight/panels/active_record_panel.rb', line 3
def initialize(app)
super
table_setup("active_record")
probe(self) do
instrument "ActiveRecord::Base" do
class_probe :allocate
end
end
end
|
Instance Method Details
#after_detect(method_call, timing, results, args) ⇒ Object
19
20
21
|
# File 'lib/insight/panels/active_record_panel.rb', line 19
def after_detect(method_call, timing, results, args)
@records[method_call.object.base_class.name] += 1
end
|
#content_for_request(number) ⇒ Object
39
40
41
42
|
# File 'lib/insight/panels/active_record_panel.rb', line 39
def content_for_request(number)
records = retreive(number).first.to_a.sort_by { |key, value| value }.reverse
render_template "panels/active_record", :records => records
end
|
#heading_for_request(number) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/insight/panels/active_record_panel.rb', line 31
def heading_for_request(number)
record = retrieve(number).first
total = record.inject(0) do |memo, (key, value)|
memo + value
end
"#{total} AR Objects"
end
|
#name ⇒ Object
27
28
29
|
# File 'lib/insight/panels/active_record_panel.rb', line 27
def name
"active_record"
end
|
#request_finish(env, status, headers, body, timing) ⇒ Object
23
24
25
|
# File 'lib/insight/panels/active_record_panel.rb', line 23
def request_finish(env, status, , body, timing)
store(env, @records)
end
|
#request_start(env, start) ⇒ Object
15
16
17
|
# File 'lib/insight/panels/active_record_panel.rb', line 15
def request_start(env, start)
@records = Hash.new{ 0 }
end
|