views:

35

answers:

1

I have a service that processes relatively "expensive" requests. The average request rate is expected to be around 5-10 per minute. I would like to be able to monitor this rate with a custom performance counter, but all the available counter types seem to be geared toward much more frequently occurring events.

What would be the best way to expose this rate through a performance counter? Perhaps I could just track the total number of events that have occurred, together with the total time elapsed, and then calculate the average and code and expose it through a NumberOfItems32? What seems a bit weird about that is that it wouldn't use the same "averaging window" as the properly managed counters.

A: 

"What would be the best way to expose this rate through a performance counter? Perhaps I could just track the total number of events that have occurred, together with the total time elapsed, and then calculate the average and code and expose it through a NumberOfItems32? What seems a bit weird about that is that it wouldn't use the same "averaging window" as the properly managed counters."

You have your solution right there. Keeping track of the number of items and the time is the only way to get the average you're looking for.

http://msdn.microsoft.com/en-us/library/system.diagnostics.performancecounter.aspx

Justin