Class: Insight::CachePanel
- Inherits:
-
Panel
- Object
- Panel
- Insight::CachePanel
show all
- Defined in:
- lib/insight/panels/cache_panel.rb,
lib/insight/panels/cache_panel/stats.rb,
lib/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, #call, current_panel_file, excluded, file_index, from_file, #has_content?, inherited, 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 CachePanel.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/insight/panels/cache_panel.rb', line 8
def initialize(app)
super
probe(self) do
instrument("Memcached") do
instance_probe :decrement, :get, :increment, :set, :add,
:replace, :delete, :prepend, :append
end
instrument("MemCache") do
instance_probe :decr, :get, :get_multi, :incr, :set, :add, :delete
end
instrument("Dalli::Client") do
instance_probe :perform
end
end
table_setup("cache")
end
|
Instance Method Details
#after_detect(method_call, timing, args, result) ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/insight/panels/cache_panel.rb', line 38
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}" }
@stats.record_call(method, timing.duration, !result.nil?, key)
end
|
#content_for_request(number) ⇒ Object
61
62
63
64
65
|
# File 'lib/insight/panels/cache_panel.rb', line 61
def content_for_request(number)
logger.debug{{ :req_num => number }}
stats = retreive(number).first
render_template "panels/cache", :stats => stats
end
|
#heading_for_request(number) ⇒ Object
55
56
57
58
59
|
# File 'lib/insight/panels/cache_panel.rb', line 55
def heading_for_request(number)
stats = retreive(number).first
"Cache: %.2fms (#{stats.queries.size} calls)" % stats.time
end
|
#name ⇒ Object
51
52
53
|
# File 'lib/insight/panels/cache_panel.rb', line 51
def name
"cache"
end
|
#panel_app ⇒ Object
47
48
49
|
# File 'lib/insight/panels/cache_panel.rb', line 47
def panel_app
PanelApp.new
end
|
#request_finish(env, st, hd, bd, timing) ⇒ Object
33
34
35
36
|
# File 'lib/insight/panels/cache_panel.rb', line 33
def request_finish(env, st, hd, bd, timing)
logger(env).debug{ "Stats: #@stats" }
store(env, @stats)
end
|
#request_start(env, start) ⇒ Object
29
30
31
|
# File 'lib/insight/panels/cache_panel.rb', line 29
def request_start(env, start)
@stats = Stats.new
end
|