How To: Custom Performance Counters with intervals other than 1 second?

  • Thread starter Thread starter Mountain
  • Start date Start date
M

Mountain

I want to implement a custom performance counter for monitoring errors
in my application. However, the correct rate is not exceptions per
second!

(If my app is throwing multiple exceptions per second, then the last
thing I need to be doing is writing custom performance counters!)

I want to implement a counter that has a period of 1 hour. What is the
right way (or best way) to do this? I figure out one way, but I had to
implement all the code and not use any of the methods in the
Diagnostics namespace (other than just setting the raw value of my
counter).

I don't think that is the right way to do it. Although all the
framework code seems to assume periodicity of 1 sec, I have a feeling I
should be able to use the framework methods and obtain rates per hour
-- I just need some help figuring out the way to go about it.

Thanks
 
Mountain said:
I want to implement a counter that has a period of 1 hour. What is the
right way (or best way) to do this? I figure out one way, but I had to
implement all the code and not use any of the methods in the
Diagnostics namespace (other than just setting the raw value of my
counter).

Hi, Mountain. Our team has dealt with this problem also, and in the end we
decided to primarily use "total" counters, which simply count all
occurrences of the event since the application began (or even ever). Once
you have this, you can easily construct a tool that takes regular samples
and takes differences to construct a plot at any rate you desire.
Unfortunately Performance Monitor does not have this useful capability
built-in, but once you create such a tool you can use it in diverse
circumstances. I hope this helps.
 
Hi Derrick,
Thank you for your reply. It seems there are only 2 options: do it like
you did, or write a performance extension DLL. I'm not sure writing a
performance extension DLL is worth the effort given that the approach
you describe should work just as well.
Regards,
Mountain
 
Back
Top