Query Application Block Instrumentation

The Enterprise Library plugs into three different instrumentation features: Performance Counters for performance monitoring, Event Logging for failure logging mainly and WMI Events again for tracking failures.

Instrumentation is configured through the Configuration Console

Adding Instrumentation

Once Instrumentation has been added to your configuration you can switch on the various features from the property window

Turning on Performance Counters

Performance Counters

The following tables describes the Query Application Block performance counters:

Performance CounterDescription
Total Query Read CountThe total number of records read
Custom Query Read CountThe total number of custom records read
Data Query Read CountThe total number of data records read
File Query Read CountThe total number of file records read
Service Query Read CountThe total number of service records read
Total Query ReadsThe total number of read operations
Custom Query ReadsThe total number of custom read operations
Data Query ReadsThe total number of data read operations
File Query ReadsThe total number of file read operations
Service Query ReadsThe total number of service read operations
Total Query WritesThe total number of write operations
Custom Query WritesThe total number of custom write operations
Data Query WritesThe total number of data write operations
File Query WritesThe total number of file write operations
Service Query WritesThe total number of service write operations
Query Read Count RateThe rate of records read per second
Custom Query Read Count RateThe rate of custom records read per second
Data Query Read Count RateThe rate of data records read per second
File Query Read Count RateThe rate of file records read per second
Service Query Read Count RateThe rate of service records read per second
Query Read RateThe rate of reads per second
Custom Query Read RateThe rate of custom reads per second
Data Query Read RateThe rate of data reads per second
File Query Read RateThe rate of file reads per second
Service Query Read RateThe rate of service reads per second
Query Write RateThe rate of writes per second
Custom Query Write RateThe rate of custom writes per second
Data Query Write RateThe rate of data writes per second
File Query Write RateThe rate of file writes per second
Service Query Write RateThe rate of service writes per second


If you have switched on Performance Counters through the Configuration Console then you can use Performance Monitor to track Query Application Block usage by selecting the Performance administrative tool from the start menu.

Before you use the performance monitor you will need to load your application that uses the Query Application Block. This is required so that performance monitor can attach itself to your query instances.

When you load performance monitor, first remove the default counters and then add the Query Application Block counters that you need. Select the computer that is running your application, select Enterprise Library Query Counters from the performance object combo box and select any of the above listed performance counters from the counters list. Note: the instances list will show you all the query instances that you have currently loaded.

Adding Query Application Block Performance Counters

As you use your application you will see the performance monitor display the values of your counters graphically, showing things like the total number of data reads, the total number of records that your application has accessed from a relational database since starting the monitor, total number of file reads and the total number of records read from files as in this example below.

Monitoring Performance

Event Log Entries

If event logging is switched on then all Query Application Block failures are logged to the Windows NT Application Event Log, the event log source name is Enterprise Library Query and the entry is described as an Error. Logged events include the following:

ListenerEventExceptionMain MessageAdditional
QueryInstrumentationListenerQueryFailedtrueThe error occurred using the instance name instance.Any general exception
DefaultQueryEventLoggerQueryConfigurationFailuretrueThe error occurred retrieving the configuration for instance instance name.Errors from the Configuration Console
DefaultQueryEventLoggerQueryFailuretrueThe error occurred using the instance name instance.Alternative general exception handler


Query Application Block Event Log Entries

WMI Events

With WMI Events switched on then the Query Application Block is instrumented with the following Windows Management Instrumentation (WMI) events: All WMI events are registered under the namespace of root\EnterpriseLibrary
The following tables describe each WMI event's properties.

Table 1: QueryFailureEvent Properties
WMI PropertyDescription
ErrorMessageThe error message that describes the failed query activity.
ExceptionMessageThe message for the exception that was raised when the query activity failed.
InstanceNameThe ID of the query that suffered the failure, as specified in the configuration file.
UtcTimeStampThe time that the query activity failed.


Table 2: QueryConfigurationFailureEvent Properties
WMI PropertyDescription
ExceptionMessageThe message for the exception that was raised when the attempt to create or configure a query failed.
InstanceNameThe ID of the query that could not be created or configured, as specified in the configuration file.
UtcTimeStampThe time that the configuration failure occurred.


A good tool to use is the WMI CIM Studio tool available as a free download:

WMI CIM Studio

For more information see the documentation that comes with the Enterprise Library 4.1