This wraps calls to the WSGI application with cProfile, storing the output and providing useful graphs for the user to view.
If the current path info refers to a specific session_uuid, this session will be removed. Otherwise, if it refers to all, then all tracked session info will be removed.
Returns a WSGI application.
Uses mako templating lookups to retrieve the template file. If the file is ever changed underneath, this function will automatically retrieve and recompile the new version.
Displays all available profiles in list format.
Returns a WSGI application.
Serves up static files relative to MEDIA_DIR.
Returns a WSGI application.
Used to display rendered graphs; if the graph that the user is trying to access does not exist–and the session_uuid exists in our history–it will be rendered.
This also creates a thumbnail image, since some of these graphs can grow to be extremely large.
Returns a WSGI application.
Helper function for wrapping an application with linesman. This can be used when manually wrapping middleware, although its also possible to simply call ProfilingMiddleware directly.
Prepares a graph for display. This includes:
- removing subgraphs based on a cutoff time
- breaking cycles
Returns a tuple of (new_graph, removed_edges)
Creates a single paste filter. Full documentation can be found in the paste docs.
Factory for creating paste filters. Full documentation can be found in the paste docs.
This function generates the fields used by the pie graph jQuery code on the session profile page. This process is clever about calculating total time, so that packages and subpackages don’t overlap.
Additionally, if I were to track linesman.middleware, and in that package an external package is called, say re, the time spent in re would be added to the total time in package linesman.middleware, unless re is one of the fields that are being tracked.
Returns a dictionary where the keys are the same as the fields, plus an extra field called Other that contains packages that were not tracked. The values for each field is the total time spent in that package.
Warning
This will run into issues where separate packages rely on the same core set of functions. I.e., of PackageA and PackageB both rely on re, there’s no defined outcome. Whichever one is parsed first will include the time spent in re.