StreamInsight | Code SampleAugust 05, 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.
/// 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(
settings.Aspects |= DiagnosticAspect.PerformanceCounters;
settings.Aspects &= DiagnosticAspect.PerformanceCounters;