views:

51

answers:

1

We're updating our ancient internal PHP application at work. Right now, we gather extensive performance measurements on every pageview, and log them to the database. Additionally, users requested that some of the metrics be displayed at the bottom of the page. This worked out pretty well for us, because the last thing that the application does on every request is include the file containing the HTML footer. The footer code calls the function to log the performance metrics to the database, and returns them for inclusion in the output to the user.

The updated parts of the application use an MVC framework and a Dispatch/Request/Response loop. The page footer is no longer the last thing done. In fact, it could very well be the first thing done, before the rest of the page is created.

Because we can grab the Response before it's returned to the user, we could try to include placeholders for the performance metrics in the footer and simply replace them with the actual numbers, but this strikes me as a bad idea somehow.

How do you handle this in your modern web app? While we're using PHP, I'm curious how it's done in a Ruby/Rails app, and in your favorite Python framework.

+1  A: 

IN Zend Framework for PHP we have overloaded postDispatch() where we attach a partial that calls a helper that collects the final metrics (at least I believe this is how we do it). Another way is for us to overload the Zend Framework response object to append it after the render action.

RoR has the same ability (overloading every step of the render) and I'm sure most MVC frameworks will as well. As a note I remember CodIgniter had automatic debug information when in development mode, it should be a simple case of finding where that is rendered and simulating it.

Good luck.

Matt S
I'll have to look at CodeIgniter's way of doing it. Our "framework" is home-grown and is maybe a few dozen lines in total right now.
Charles