开发者

Displaying performance metrics in a modern web app?

开发者 https://www.devze.com 2023-01-01 06:20 出处:网络
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

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 foot开发者_Python百科er 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号