Understanding Visual Studio Analyzer Filters

   

Visual Studio Analyzer has the potential to generate more events than you want or need. Too many events can put stress on the network and obscure the events that are important for analysis. To avoid this kind of event overload, Visual Studio Analyzer provides a filtering mechanism. This filtering mechanism is used at two points in the analysis process:

The filtering mechanism consists of one or more filters. Filters are normal Boolean expressions. They describe a combination of machines, processes, components, event categories, events, and other fields using Boolean operators such as AND and OR.

Types of Filters

Visual Studio Analyzer recognizes both file-based and transient filters. The AutoFilter command works differently with file-based and transient filters. When you create a filter in Visual Studio Analyzer, or include one of the predefined filters in your project, you are using a file-based filter — a filter that resides in a file. A transient filter is a temporary filter that resides in memory only. When you select the Edit Filter command on an unfiltered view, Visual Studio Analyzer creates a transient filter.

Predefined Filters

Some predefined filters are available for filtering standard types of events. These filters are installed when you run the Visual Studio Analyzer Wizard to create a project. You can add any predefined filter to your project by selecting the Filters node in the Project Explorer, right-clicking to display the shortcut menu, and clicking Add Predefined Filter. Once added, you can modify a predefined filter as required.

Blank Filters

When you add a blank filter, it is a filter with nothing selected. If your Visual Studio Analyzer project does not contain any other filters, this filter is the recording filter, and no Visual Studio Analyzer events are collected when you run your application. Visual Studio Analyzer is intentionally set up this way because the opposite case, a generic filter that selects all events from all event sources on all machines, would generate too much data and might cripple the network.

Creating Filters

You create a filter by right-clicking the Filters node in the Project Explorer pane of the Microsoft development environment and clicking Add Item on the shortcut menu. Then you use the Filter Editor to define the filter. See Creating and Refining Visual Studio Analyzer Filters for step-by-step procedures.

Filters During Collection and Analysis

You can set a filter as the recording filter, to determine what events are collected from your application. When you open an event log in a view, you can apply a filter to a view to refine the amount of data you see.

There is a difference between setting a filter as the recording filter and applying a filter to a view. The recording filter determines what events are collected from your application; a filter applied to a view refines the existing data displayed in that view.

The important difference is how Visual Studio Analyzer treats machines and components. During event recording, only events generated by the machines and components identified in the recording filter are recorded. When viewing data, only records with the machines and components identified in the applied filter are displayed. Although it might seem that these two actions are identical, such is not always the case.

For example, imagine that components A and B make up an application. Suppose the applied filter specifies Component=B and you are viewing events. In this case, an event that A generated, indicating communication from A to B would be displayed. However, if the recording filter specifies Component=B and you are recording events, an event that A generated, indicating communication from A to B, would not be recorded because Component=A is not explicitly specified in the filter.

This difference between event recording and event viewing allows Visual Studio Analyzer to limit the amount of data collected and subsequently passed over the network. What this means to you is that when you are recording events, you must be careful to explicitly select all participating components in your recording filter. When you are viewing events, you can be more liberal in your filter selections.

Avoiding Too Much Data

You need to construct filters thoughtfully, keeping network performance in mind. Each item you specify narrows the focus. For example, if you suspect a performance problem between machines, but you don't know which machines, you might try selecting subsets of your machines and running your application repeatedly.

Note   Be careful when defining Performance Monitor events in your initial filter. Visual Studio Analyzer will warn you if you try to specify all Performance Monitor events in a filter because the overhead is prohibitive: each Performance Monitor counter will be fired at very frequent intervals, such as every half-second. The resulting events would overload the network and severely compromise Visual Studio Analyzer performance.

Applying a Filter to a Visual Studio Analyzer View

When you open one of Visual Studio Analyzer's views, the view is auto filtered — that is, the filter that is applied to the view is the same filter applied to any other open views. If no filter is applied to any other open view, or if there are no other views open, the view is unfiltered and all data is displayed.

You can apply the recording filter to the view. You can apply a different filter — or modify the applied filter — to change the events shown in the view. To apply filters to views, you use the Apply Filter command on the shortcut menu. If you have more than one view open, you can:

Refining Filters to Target Specific Information

You can edit the filter applied to a view at any time to narrow down the events shown in the view. As soon as you finish editing the filter, the view updates to reflect your changes. Other open views that have the same filter applied also change. Normally your initial filter will be quite broad, encompassing many components and events. Once you gather your initial set of data, part of your analysis process consists of refining what you collected to eliminate components or events that do not show evidence of a problem. If you open another view after editing the active filter, the view reflects the changes you made.

Filter Files

You can share filters among Visual Studio Analyzer projects. A Visual Studio Analyzer filter is stored as a text file with the .vaf extension. You can save a filter and then copy the filter to other Visual Studio Analyzer projects. You can open a saved filter and include it with your Visual Studio Analyzer project. The name of the current filter is displayed on the viewer title bar.

When you change a saved filter, all open views to which that filter is applied will refresh their data, unless they are explicitly unlinked from the filter. See Creating and Refining Visual Studio Analyzer Filters for the steps to unlink views from the active filter.