Registering New Event Categories with Visual Studio Analyzer

   

You can use event categories to group related events, partly to make it easier to locate the events within the event log, and partly to provide context for the kinds of interaction events represent. A typical Visual Studio Analyzer event log can contain thousands of events; categories provide a way to locate particular events more quickly. The Visual Studio Analyzer user can see categories listed within the Filter Editor.

If you choose to use event categories, you can use those that Visual Studio Analyzer provides, or you can define your own. The following table lists those that Visual Studio Analyzer provides:

Predefined Event Category Description
DEBUG_EVENT_CATEGORY_STARTSTOP Events generated by components starting or shutting down.
DEBUG_EVENT_CATEGORY_CALLRETURN Events generated by the function calls and returns.
DEBUG_EVENT_CATEGORY_QUERYRESULT Events generated by the starting and completing of database queries.
DEBUG_EVENT_CATEGORY_TRANSACTION Events generated by transactions, including start, commit, and rollback.
DEBUG_EVENT_CATEGORY_ALL All events.
DEBUG_EVENT_CATEGORY_MEASURED_ALL All measured events. A measured event is generated by a dynamic event source and signifies a measurement of an item, such as CPU usage.

Add the code for registering event categories to your component installation or startup code after the code for registering your component with Visual Studio Analyzer.

Defining Custom Event Categories

You must take the following steps with code in your component in order to register your custom event categories.

  1. Register your component with Visual Studio Analyzer.

    If you want your component to generate Visual Studio Analyzer events, you must add code that will register the component with Visual Studio Analyzer. See Registering New Components with Visual Studio Analyzer for information on how to do this.

  2. Call the RegisterEventCategory method of the event source installer object for each category you want to define.

    The RegisterEventCategory method registers the name and ID of each event category.

    You can arrange categories in a hierarchy with the guidParentID parameter. A hierarchy allows you to define additional levels of categorization. For example, consider the Visual Studio Analyzer events that Performance Monitor generates. These events are categorized to represent the different objects and instances that are providing performance data.

    If you register categories without specifying the guidParentID parameter, your categories will be displayed in the Filter Editor at the same level (top) as the All Events category. If you want your categories to appear subordinate to the All Events category, specify DEBUG_EVENT_CATEGORY_ALL for guidParentID.

    The interface exposed by the event source installer object is not a dual interface; therefore, the version of the interface you use depends on the language in which your component is written.

    Language Event Installer Interface
    Visual Basic, Visual J++ IsystemDebugEventInstallAuto
    Visual C++ ISystemDebugEventInstall

    If your component is not COM-enabled, use the Visual Studio Analyzer standard RPC interface, VsaRpcl.

  3. Register the events you plan to generate.

    You can use any of the Visual Studio Analyzer system-defined events with your component, but you must register each event that you plan to generate. See Registering New Events with Visual Studio Analyzer for information on how to do this.