Class: Rack::Bug::SpeedTracerPanel

Inherits:
Panel
  • Object
show all
Defined in:
lib/rack/bug/panels/speedtracer_panel.rb,
lib/rack/bug/panels/speedtracer_panel/database.rb,
lib/rack/bug/panels/speedtracer_panel/instrumentation.rb

Defined Under Namespace

Classes: Database, Instrumentation, Middleware

Instance Attribute Summary

Attributes inherited from Panel

#request

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Panel

#call, #has_content?, #render

Methods included from Render

#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params

Constructor Details

#initialize(app) ⇒ SpeedTracerPanel

Returns a new instance of SpeedTracerPanel.



72
73
74
75
# File 'lib/rack/bug/panels/speedtracer_panel.rb', line 72

def initialize(app)
  @app  = app
  super
end

Class Method Details

.databaseObject



47
48
49
# File 'lib/rack/bug/panels/speedtracer_panel.rb', line 47

def database
  @db ||= make_database
end

.make_databaseObject



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rack/bug/panels/speedtracer_panel.rb', line 51

def make_database
  require 'rack/bug/panels/speedtracer_panel/database'
  return Database.new("speedtracer")
rescue Object => ex
  msg = "Speedtracer issue while loading SQLite DB:" + [ex.class, ex.message, ex.backtrace[0..4]].inspect 
  if Rails.logger
    Rails.logger.debug msg
  else
    puts msg
  end

  return {}
end

Instance Method Details

#after(env, status, headers, body) ⇒ Object



106
107
# File 'lib/rack/bug/panels/speedtracer_panel.rb', line 106

def after(env, status, headers, body)
end

#before(env) ⇒ Object



103
104
# File 'lib/rack/bug/panels/speedtracer_panel.rb', line 103

def before(env)
end

#contentObject



89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/rack/bug/panels/speedtracer_panel.rb', line 89

def content
  traces = database.to_a.sort do |one, two|
    two[1].start <=> one[1].start
  end
  advice = []
  if not defined?(Yajl)
    advice << "yajl-ruby not installed - Speedtracer server events won't be available"
  end
  if not defined?(SQLite3)
    advice << "sqlite3 not installed - Speedtracer will behave oddly if run behind a forking webserver"
  end
  render_template "panels/speedtracer/traces", :traces => traces, :advice => advice
end

#databaseObject



68
69
70
# File 'lib/rack/bug/panels/speedtracer_panel.rb', line 68

def database
  self.class.database
end

#headingObject



85
86
87
# File 'lib/rack/bug/panels/speedtracer_panel.rb', line 85

def heading
  "#{database.keys.length} traces"
end

#nameObject



81
82
83
# File 'lib/rack/bug/panels/speedtracer_panel.rb', line 81

def name
  "speedtracer"
end

#panel_appObject



77
78
79
# File 'lib/rack/bug/panels/speedtracer_panel.rb', line 77

def panel_app
  return SpeedTrace::TraceApp.new(database)
end