Here is a question I get asked from developers:

"Why should I instrument my application?"

Why indeed? Does anyone ever look at it? Does anyone care?

So what scenario is powerful enough to get a few extra lines of code added to a project? (Ok so its more than just adding a few lines of code here and there, you have to think first, which takes considerably more effort)

Picture this 1am - Saturday morning, phone goes, it’s the data centre guy who keeps bugging you. Your app has crashed and they have no idea how to fix it, they tried restarting the box, but that has not worked. Can you pop in?

Not sure about you, but that does not seem good to me.

How about this one.

1am - Saturday morning. Application raises a WMI event, it could not write to the log file, because of some error. WMI event is spotted by Microsoft Operations Manager 2005. It responds by running a WMI script to check the disk space on the drive containing the log file. The script reports that the disk is full. MOM responds by running another script to alter the location for the Log file used by the application and restarts the application. Since this is a temporary measure, an administrative alert is created, and an email is sent reporting the problem, and the automated quick fix. Monday - you arrive at work and find an email reporting the weekends events. You call the data centre guy and they report that are already on the problem and everything is fine and back to normal. Phew, might have had to do some work there.

Fact - Administrators do use WMI & scripts. There is a whole world of scripting available at http://www.microsoft.com/technet/scriptcenter/default.mspx and many scripts use WMI.

In our example above, all we had to do was expose some event to the platform that could be acted upon, in this case by MOM. However it does not stop there. Using WMI you can expose any information about your application you wish, including configuration information, performance data, statistics - anything. Administrators can then inspect your application using tools and techniques they are familiar with. If done correctly, this leads to your application being more manageable, which in turn will reduce the overall TCO of your application.

So back to the question, Why instrument you application?

To make it cheaper and better to operate.

THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS