Class: Insight::SQLPanel
- Defined in:
- lib/insight/panels/sql_panel.rb,
lib/insight/panels/sql_panel/query.rb,
lib/insight/panels/sql_panel/panel_app.rb
Defined Under Namespace
Classes: ExplainResult, PanelApp, ProfileResult, QueryResult
Instance Attribute Summary
Attributes inherited from Panel
Class Method Summary collapse
Instance Method Summary collapse
- #after_detect(method_call, timing, arguments, results) ⇒ Object
- #content_for_request(number) ⇒ Object
- #heading_for_request(number) ⇒ Object
-
#initialize(app) ⇒ SQLPanel
constructor
A new instance of SQLPanel.
- #name ⇒ Object
- #total_time(queries) ⇒ Object
Methods inherited from Panel
#after, #before, #call, current_panel_file, excluded, file_index, from_file, #has_content?, inherited, #panel_app, panel_exclusion, #render
Methods included from Instrumentation::Client
#before_detect, #probe, #request_finish, #request_start
Methods included from Logging
Methods included from Database::RequestDataClient
#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
#initialize(app) ⇒ SQLPanel
Returns a new instance of SQLPanel.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/insight/panels/sql_panel.rb', line 10 def initialize(app) super probe(self) do %w{ PostgreSQLAdapter MysqlAdapter SQLiteAdapter Mysql2Adapter OracleEnhancedAdapter }.each do |adapter| instrument "ActiveRecord::ConnectionAdapters::#{adapter}" do instance_probe :execute end end end table_setup("sql_queries") end |
Class Method Details
Instance Method Details
#after_detect(method_call, timing, arguments, results) ⇒ Object
27 28 29 |
# File 'lib/insight/panels/sql_panel.rb', line 27 def after_detect(method_call, timing, arguments, results) store(@env, QueryResult.new(arguments.first, timing.duration, method_call.backtrace, results)) end |
#content_for_request(number) ⇒ Object
46 47 48 49 |
# File 'lib/insight/panels/sql_panel.rb', line 46 def content_for_request(number) queries = retrieve(number) render_template "panels/sql", :queries => queries end |
#heading_for_request(number) ⇒ Object
41 42 43 44 |
# File 'lib/insight/panels/sql_panel.rb', line 41 def heading_for_request(number) queries = retrieve(number) "#{queries.size} Queries (%.2fms)" % total_time(queries) end |
#name ⇒ Object
37 38 39 |
# File 'lib/insight/panels/sql_panel.rb', line 37 def name "sql" end |
#total_time(queries) ⇒ Object
31 32 33 34 35 |
# File 'lib/insight/panels/sql_panel.rb', line 31 def total_time(queries) (queries.inject(0) do |memo, query| memo + query.time end) end |