Rack::Bug debugging toolbar in four minutes

Here’s a quick screencast demonstrating Rack::Bug, a new Rack middleware for inspecting requests to any Rack-compatible web application.

Download the screencast (12 MB, 4:00)

The source is on GitHub. It ships with nine panels:

  • Rails Info
  • Resource Usage
  • Rack Env
  • SQL
  • AR Objects
  • Memcached
  • Templates
  • Log
  • Memory Usage
./script/plugin install git://github.com/brynary/rack-bug.git
1
2
3
4
5
6
7
# config/initializers/middleware.rb
require "rack/bug"

ActionController::Dispatcher.middleware.use Rack::Bug,
  :ip_masks   => [IPAddr.new("127.0.0.1")],
  :secret_key => "epT5uCIchlsHCeR9dloOeAPG66PtHd9K8l0q9avitiaA/KUrY7DE52hD4yWY+8z1",
  :password   => "rack-bug-secret"

13 Responses to “Rack::Bug debugging toolbar in four minutes”

  1. # Wilson Bilkovich Says:

    Hell. Yeah.

  2. # Raul Murciano Says:

    Impressive work Bryan!

  3. # Benjamin Stein Says:

    That’s real hot.

  4. # Bradly Feeley Says:

    Wow. Definitely one of the coolest uses of Rack yet.

  5. # Kieran P Says:

    Nice work! Would love to see this as a gem with ~/.rack-bug settings (for multiple apps)

  6. # Bill Kayser Says:

    Nice! One small tip. Calling Rails::Info.properties has an unfortunate side effect in defining the ActiveRecord module. A lot of Rails code checks defined? ActiveRecord (including your own!) to determine whether ActiveRecord is loaded, so if the app does not include the ActiveRecord framework, you can start seeing errors after invoking Rails::Info.properties.

    It seems like this should be fixed in Rails by calling defined? ActiveRecord::Base but I’m not 100% sure.

  7. # John Schult Says:

    ”...a new Rack middleware for inspecting requests to any Rack-compatible web application”. How does one use this with something other than Rails and AR (Datamapper)?

  8. # Kai König Says:

    Nice work, this will be very useful for many developers as they can now easily track down bottlenecks in their apps

    But… That green, its just awful

    cheers

  9. # My maps Says:

    Blog added to my favorites! :-)

  10. # Rupak Ganguly Says:

    Bryan, thanks a lot. This is VERY helpful. By the way, for Windows users who are having issues with installing plugins from Github, see my post: http://rails.webintellix.com/index.php/2009/05/installing-rails-plugins-from-github-on-windows/

  11. # Gnagno Says:

    Hello,

    am I the only one getting errors after installing this plugin? it seems very promising indeed but I can’t use it.

    I installed via ./script/plugin install git://github.com/brynary/rack-bug.git and everything went fine, so I added the file middleware.rb and filled it with the code you gave us; then when I try to start the server I get a lot of errors, if I delete the file middleware.rb the server is working again.

    can someone please help me?

    Thanks in advance Gnagno

  12. # Gnagno Says:

    Sorry,

    I’ve found the problem is that I was using rails 2.2, is there a version of this fantastic midleware for rails 2.2 ?

    thanks Gnagno

  13. # linoj Says:

    hi, i just installed (in rails 2.3.2) and getting uninitialized constant Digest::SHA1 ??