OpsMgr 2007: Monitoring .NET Application Performance

With all the interest around creating custom OpsMgr 2007 solutions, I thought I'd write a simple code sample to help app development teams instrument their code to further gain value from OpsMgr 2007. Keep in mind the attached sample is just that - a sample (not product ready code), but it paints a clear picture.


Instrument business functions in your .NET applications so that you can track the performance of each business function. While in this example, I have only demonstrated how to capture and track the duration it takes for each function to execute, you can build on this idea to include a variety of quality measures, such as, CPU utilization, memory utilization, number of failures, who executed the function, number of times it was executed in a given period and so on.


  • Gain insights into the applications at a business-function level (a business function can be anything, such as a login, product lookup etc.)

  • Use your existing IT investment (in OpsMgr 2007) to monitor applications at a very detailed level.

  • Understand the true cost (from an physical resource perspective) of each business function.

  • Examine overall application performance and impact to applications after upgrades or releases.

  • For eCommerce websites and applications, this is especially useful, as it builds the framework for you to correlate business function performance with revenue (lost or gained).

How to use the sample:

  • Open the attached sample (see file link below) in Visual Studio 2005 Professional or greater and set the PerformanceManagementWeb project as the startup project.

  • Make sure you open the solution as a local administrator so that it can create the performance counter when you run it the first time.

  • Build and execute the solution by hitting F5. Your web browser will open, at which point click the “Create Counters” button.  By doing this you do this it will create the necessary performance counters on your machine (which is only required the first time you run this sample).

  • Open Perfmon and add the counter GetCustomerProfile, which will be listed under the performance counter category ApplicationPlatformName

  • Now that the counters are created, you can click on the “Execute Method” button to see the values of the performance counter change.

Click here for the sample code

What is the sample doing?

Every time you click on the “Execute Method”, you are simulating the execution of a business function called "GetCustomerProfile", in which, for example, you could be loading the profile of one of your eCommerce customers. The idea is to publish (i.e. instrument) key areas of the application as performance counters so that it can be monitored by OpsMgr 2007/MOM 2005.

So how could this be useful?  Just to give you a single example, imagine if you could receive an alert that logins on your eCommerce website are taking longer than normal and you could respond to it immediately before your customers left the site to purchase the product elsewhere?

That's just one example of how instrumenting your code can reduce down time and increase efficiency but with a little imagination I'm sure you can come up with countless ways this can improve your business.


David Raskino | Microsoft Consulting Services


Comments (1)

Skip to main content