Class: Insight::ActiveResourcePanel
- Defined in:
- lib/insight/panels/active_resource_panel.rb,
lib/insight/panels/active_resource_panel/query.rb
Defined Under Namespace
Classes: RequestResult
Instance Attribute Summary
Attributes inherited from Panel
Instance Method Summary collapse
- #after_detect(method_call, timing, arguments, results) ⇒ Object
- #content_for_request(number) ⇒ Object
- #heading_for_request(number) ⇒ Object
-
#initialize(app) ⇒ ActiveResourcePanel
constructor
require “insight/panels/sql_panel/panel_app” require “insight/panels/sql_panel/query”.
- #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, panel_mappings, #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) ⇒ ActiveResourcePanel
require “insight/panels/sql_panel/panel_app” require “insight/panels/sql_panel/query”
9 10 11 12 13 14 15 16 17 |
# File 'lib/insight/panels/active_resource_panel.rb', line 9 def initialize(app) super probe(self) do instrument "ActiveResource::Connection" do instance_probe :request end end table_setup("active_resource_requests") end |
Instance Method Details
#after_detect(method_call, timing, arguments, results) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/insight/panels/active_resource_panel.rb', line 19 def after_detect(method_call, timing, arguments, results) body = "<no body>" if results.respond_to? :body body = results.body end store(@env, RequestResult.new(arguments[0], arguments[1..-1], timing.duration, method_call.backtrace[0..5], body)) end |
#content_for_request(number) ⇒ Object
42 43 44 45 46 |
# File 'lib/insight/panels/active_resource_panel.rb', line 42 def content_for_request(number) queries = retrieve(number) logger.debug{ "ARes: #{queries.inspect}" } render_template "panels/active_resource", :queries => queries end |
#heading_for_request(number) ⇒ Object
37 38 39 40 |
# File 'lib/insight/panels/active_resource_panel.rb', line 37 def heading_for_request(number) queries = retrieve(number) "ARes: #{queries.size} Queries (%.2fms)" % total_time(queries) end |
#name ⇒ Object
33 34 35 |
# File 'lib/insight/panels/active_resource_panel.rb', line 33 def name "active_resource" end |
#total_time(queries) ⇒ Object
27 28 29 30 31 |
# File 'lib/insight/panels/active_resource_panel.rb', line 27 def total_time(queries) (queries.inject(0) do |memo, query| memo + query.time end) end |