Class: Rack::Insight::ActiveRecordPanel

Inherits:
Panel
  • Object
show all
Defined in:
lib/rack/insight/panels/active_record_panel.rb

Instance Attribute Summary

Attributes inherited from Panel

#request

Instance Method Summary collapse

Methods inherited from Panel

#after, #before, #bool_prop, #call, #camelized_name, #content, current_panel_file, excluded, file_index, from_file, #handle_error_for, #has_content?, #has_custom_probes?, has_table, #has_table?, #heading, inherited, #initialize, #inspect, #is_magic?, #is_probing?, #name, #panel_app, panel_exclusion, panel_mappings, #render, set_sub_class_template_root, #underscored_name

Methods included from Database::EigenClient

included

Methods included from Instrumentation::EigenClient

included

Methods included from Logging

logger, verbose, verbosity

Methods included from Instrumentation::Client

#before_detect, #probe

Methods included from Database::RequestDataClient

#count, #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

This class inherits a constructor from Rack::Insight::Panel

Instance Method Details

#after_detect(method_call, timing, results, args) ⇒ Object



8
9
10
# File 'lib/rack/insight/panels/active_record_panel.rb', line 8

def after_detect(method_call, timing, results, args)
  @records[method_call.object.base_class.name] += 1
end

#content_for_request(number) ⇒ Object



24
25
26
27
# File 'lib/rack/insight/panels/active_record_panel.rb', line 24

def content_for_request(number)
  records = retrieve(number).first.to_a.sort_by { |key, value| value }.reverse
  render_template "panels/active_record", :records => records
end

#heading_for_request(number) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/rack/insight/panels/active_record_panel.rb', line 16

def heading_for_request(number)
  record = retrieve(number).first
  total = record.inject(0) do |memo, (key, value)|
    memo + value
  end
  "#{total} AR Objects"
end

#request_finish(env, status, headers, body, timing) ⇒ Object



12
13
14
# File 'lib/rack/insight/panels/active_record_panel.rb', line 12

def request_finish(env, status, headers, body, timing)
  store(env, @records)
end

#request_start(env, start) ⇒ Object



4
5
6
# File 'lib/rack/insight/panels/active_record_panel.rb', line 4

def request_start(env, start)
  @records = Hash.new{ 0 }
end