I’m trying to log how much time my webapp takes to answer each request.
Right now I have a metaclass for Handlers that wraps each action and calculates the time passed between entering the method and exiting. This works fine, except that the logged times do not include the time spent rendering the templates… How could I do it?
I’m trying to log how much time my webapp takes to answer each request.
Share
This is the purpose of a tween. It is middleware that wraps the Pyramid application, so it has access to both the ingress and egress of a request within Pyramid. Note that there is already the debug toolbar which displays how long the entire request took. This is also a good application for WSGI middleware of which I’m sure a package already exists or you could easily write your own.
http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/hooks.html#registering-tweens