/Watson

Some helpers for creating and using Windows performance counters.

Primary LanguageC#

Watson

yes, I'm going to change the name... it's horrible

Configure your desired custom performance counters at application startup or as part of a separate installation procedure.

new Watson
    .FluentConfigurator()
    .AddCategory("Watson.Example")
        .AddCounter("NumberOfThings")
        .AddCounter("AverageNumberOfThingsOverTime")
        .CreateOrUpdate()
    .Initialize();

Then, in your application classes that are publishing performance statistics, get a performance counter out and use it!

private static readonly PerformanceCounter _counter = WatsonManager.GetPerformanceCounter("Watson.Example.NumberOfThings");
private static readonly PerformanceCounter _avgCounter = WatsonManager.GetPerformanceCounter("Watson.Example.AverageNumberOfThingsOverTime");