It’s been more than a year since I introduced one of my projects named Rack Web Profiler.
These last months I worked to stabilise, clean the project and also export the part linked to Rails onto a separate gem.
Why this gem
I know there is existing tools to develop and debug Rack and Rails applications like the gem rack-miniprofiler. But they have some elements missing to allow customisation and easy extension.
That’s why I started creating this gem.
With Rack Web Profiler you have the ability to create custom collectors by using its DSL. It allows you to collect informations then show them on the bar and the panel.
All datas collected are stored in an SQLite database so you have access to the requests history.
For now these two gems are just bases but it could be something more in the future.
UI preview
I worked with Thomas De Cicco a digital designer on the UI of the profiler. We tried together to have something light, simple and readable.
The bar
It gives you quick informations about the current request. By clicking an element you can access more informations on the panel.
The panel
It shows you collectors details for a captured request.
You also have a page that gives you the previous requests.
How to use it
I worked to have something which works with as less configuration as possible. But the gem will come with the possibility of having some options to configure it as you like.
Rack → rack-webprofiler
With rack you need to add the profiler in the middleware like this:
By default it will use Dir.tmpdir to define the temporary directory (place where the database is created). You could configure it by using the tmp_dir: option.
For Rails the gem only contains specific collectors. It includes the rack-webprofiler gem to have the bar and panel.
It uses Railtie to automatically load the profiler in the middleware. So you only have to add one gem to the Gemfile as following:
It uses the Rails temporary directory as tmp_dir for the database place.
For now there is nothing for Sinatra but I plan working on a sinatra-webprofiler gem in the future if there are requests.
How to extend it
Like I said I worked to have something extendable easily. I created a DSL with methods to give you access to the tools you needs.
Here is an example of the time collector.
Or if it was in a separate file:
After creating the collector, you simply need to register it as following:
Registration can’t be done dynamically in your application code. If you don’t always need to show a collector, you have to use the is_enabled? DSL method.
The Rack WebProfiler will have some other functionalities in the future. Like being able to toggle the bar, have a search form for the requests list and catch the exceptions to show the informations into the panel.
I also plan to create some other collectors for Rails like I18n, ActiveMailer and ActiveJob collectors.
If you have any feedback, comment or idea of contribution, github!