Class: Insight::RedisPanel

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

Defined Under Namespace

Classes: Stats

Instance Attribute Summary

Attributes inherited from Panel

#request

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Panel

#after, #before, #call, #content_for_request, current_panel_file, excluded, file_index, from_file, #has_content?, #heading_for_request, inherited, #initialize, #panel_app, panel_exclusion, panel_mappings, #render

Methods included from Instrumentation::Client

#after_detect, #before_detect, #probe, #request_finish, #request_start

Methods included from Logging

logger

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

This class inherits a constructor from Insight::Panel

Class Method Details

.record(redis_command_args, backtrace, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/insight/panels/redis_panel.rb', line 8

def self.record(redis_command_args, backtrace, &block)
  return block.call unless Insight.enabled?

  start_time = Time.now
  result = block.call
  total_time = Time.now - start_time
  stats.record_call(total_time * 1_000, redis_command_args, backtrace)
  return result
end

.resetObject



18
19
20
# File 'lib/insight/panels/redis_panel.rb', line 18

def self.reset
  Thread.current["insight.redis"] = Stats.new
end

.statsObject



22
23
24
# File 'lib/insight/panels/redis_panel.rb', line 22

def self.stats
  Thread.current["insight.redis"] ||= Stats.new
end

Instance Method Details

#contentObject



34
35
36
37
38
# File 'lib/insight/panels/redis_panel.rb', line 34

def content
  result = render_template "panels/redis", :stats => self.class.stats
  self.class.reset
  return result
end

#headingObject



30
31
32
# File 'lib/insight/panels/redis_panel.rb', line 30

def heading
  "Redis: %.2fms (#{self.class.stats.queries.size} calls)" % self.class.stats.time
end

#nameObject



26
27
28
# File 'lib/insight/panels/redis_panel.rb', line 26

def name
  "redis"
end