About the author

J Sawyer is a developer based in Houston, TX who absolutely loves to write code. After spending 9 years at Microsoft, he moved on to other things and is currently the Lead Developer for the RealTime Data Management team at Logica US. He spends his days building Really Cool Things around StreamInsight and having a blast doing it.

He has been involved with HDNUG, one of the oldest and largest .NET-focused user groups in the US, since its inception in 2001 and has watched it grow from 5-10 technologists meeting around a conference table to a thriving community of over 5000 with regular meeting attendance averaging 100 attendees. He currently serves as the Vice President. You can join him at HDNUG on the second Thursday of every month at the Houston Microsoft office.

He also loves to ride his Yamaha FZ1. And sometimes his Ninja 650. And also his Honday XR-400 dirt bike. But he doesn't code and ride at the same time. That would be bad.

StreamInsight 1.2: Extension Method for Perf Counters

August 5, 2011 10:01 AM

One of the new features in StreamInsight 1.2 is performance counters. These give you a very robust and easy way to test and monitor performance of your StreamInsight application and were much needed. The counters are enabled at the StreamInsight Server and Application level all the time but you need to specify and enable the individual queries that you want monitored as well. Enabling a query for performance counters will also hook up both the input and the output adapters, which help you understand if you have bottlenecks or poor performance in them as well – though there is a performance hit (though relatively minimal) for this. Very cool stuff. But … like the query state … it’s a bit warty (IMHO) in some of the details. Fortunately, it’s nothing that we can’t make at least a little better through the beauty that is extension methods. I’ll go into more detail on the perf counters in a future post but I wanted to share this little piece of code to help y’all get to using these a bit quicker.

/// <summary>
/// Enables and disables performance counters for a query. 
/// </summary>
/// <param name="query"></param>
/// <param name="enabled">true to enable, false to disable.</param>
public static void SetPerformanceCounters(this Query query, bool enabled)
{
    
    Uri queryUri = query.Name;

    DiagnosticSettings settings = query.Application.Server.GetDiagnosticSettings(
                        queryUri);
    if (enabled)
    {
        settings.Aspects |= DiagnosticAspect.PerformanceCounters;
    }
    else
    {
        settings.Aspects &= DiagnosticAspect.PerformanceCounters;
    }

    query.Application.Server.SetDiagnosticSettings(queryUri, settings);

}

Tags:

StreamInsight | Code Sample