Tracking ColdFusion performance stats in a test environment for a single visitor

A client of mine recently asked me to put something together that would make it really easy for anyone to use their software and look at some simple information about the number of files they've accessed, average page load times, etc. The idea was that in addition to our standard load testing, we'd gather information from business users. I've whipped-up a little ColdFusion file in a couple of hours that allows you to view statistical information when browsing ColdFusion MX pages. It's not the most pretty or terribly robust thing in the world - just a crude way to click around inside an application, all the while viewing information like average request processing time, number of queries and stored procs run, etc.
The file is available at http://www.horwith.com/downloads/trackstats.zip. There is a simple comment at the top that should help you understand how to use it, or read on for more.

r> To use it, unzip the file into your cfusion_war\WEB-INF\debug directory for whatever server(s) you want to be able to track on then log-in to your ColdFusion Administrator, go to the "Debugging Settings" section, make sure debugging is turned on, and select the file ("trackstats.cfm") from the "Select Debugging Output Format" drop down list. Don't forget to click the "Submit Changes" button on that page. You must also make sure that any application you use this file within does not have debugging suppressed with a CFSETTING tag.
Once you've done all of the above, browse to your application and click around. Your debug panel will show statistical information for the current request as well as all requests to date. There are links to start recording (this resets the tracker), stop recording (this resets the tracker as well), reload the current request (this will pass all of the appropriate URL variables to replicate the request but it won't resubmit a form post), and turn on or off a dump of all of the information recorded to date (for this tracking session). There's also a link for viewing previously recorded tracking sessions... this does nothing by default. I've added the ability to have individual tracking sessions recorded to file and to be able to select any of these files and view the stats for that session. In order to turn this functionality on, within a request you'll need to create the following variables:

  • request.doLogging - this variable should have a value of 'true' to turn on recording to file functionality
  • request.loggingDirectory - this is the full path to the directory you want to store the session records in - it can be any valid directory path on your machine. If you don't set it and request.doLogging is 'true' then the current directory is used for any request
  • request.appName - if you (or many people) are tracking one or more applications on a server and they share a common loggingDirectory, this helps to differentiate between the files and it also keeps session tracking information for one application separate from session tracking information for another application (in memory).

This is a good way to do "single user visit" request analysis without having to install and learn how to use a load testing utility. Basically, it extends the functionality you get from "normal" CF debugging to include tracking across multiple requests and saving the information. It is simple which also means it's not very robust - you can't record actions and play them back, for example (unlike load tools, which are usually scriptable).
Use the file at your own risk (I obviously recommend only using it in development), and feel free to modify it to suit your needs. As always, if you have any questions about how to use the file, feel free to ask... and remember, I only spent a couple hours on this so don't expect anything too amazing.

Comments
This site is hosted by HostMySite and runs off of BlogCFC - thanks, Ray.