Class: Rack::Insight::CachePanel

Inherits:
Panel
  • Object
show all
Defined in:
lib/rack/insight/panels/cache_panel.rb,
lib/rack/insight/panels/cache_panel/stats.rb,
lib/rack/insight/panels/cache_panel/panel_app.rb

Defined Under Namespace

Classes: PanelApp, Stats

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_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, args, result) ⇒ Object



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

def after_detect(method_call, timing, args, result)
  method, key = method_call.method, args.first
  if(defined? Dalli and Dalli::Client === method_call.object)
    method, key = args[0], args[1]
  end
  logger.info{ "Cache panel got #{method} #{key.inspect}" } if verbose(:high)
  @stats.record_call(method, timing.duration, !result.nil?, key) if method.present?
end

#content_for_request(number) ⇒ Object



34
35
36
37
# File 'lib/rack/insight/panels/cache_panel.rb', line 34

def content_for_request(number)
  stats = retrieve(number).first
  render_template "panels/cache", :stats => stats
end

#heading_for_request(number) ⇒ Object



28
29
30
31
32
# File 'lib/rack/insight/panels/cache_panel.rb', line 28

def heading_for_request(number)
  stats = retrieve(number).first

  "Cache: %.2fms (#{stats.queries.size} calls)" % stats.time
end

#panel_appObject



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

def panel_app
  PanelApp.new
end

#request_finish(env, st, hd, bd, timing) ⇒ Object



11
12
13
# File 'lib/rack/insight/panels/cache_panel.rb', line 11

def request_finish(env, st, hd, bd, timing)
  store(env, @stats)
end

#request_start(env, start) ⇒ Object



7
8
9
# File 'lib/rack/insight/panels/cache_panel.rb', line 7

def request_start(env, start)
  @stats = Stats.new
end