Opening and Running Data Collector Sets
To run a data collector set in the RPM, simply right-click on it and then click Start. To examine the data collected by the set, expand the Reports --> User Defined nodeeither during the run or after the data collector set run completes (see
Figure 9).
 | |
Figure 9. RPM Run Information: The RPM displays detailed information about data collector set runs. |
Open and run a data collector set using the PLA API with the
IDataCollectorSet.Query and
IDataCollectorSet.start methods.
// Open the data collector set
IDataCollectorSet collectorSet =
new DataCollectorSetClass();
string name =
@"Service\DevX (Created with the PLA API)";
collectorSet.Query(name, null);
// Run the data collector set
collectorSet.start(false);
// Immediately report the status
Console.WriteLine(collectorSet.Status);
// Wait a moment and report the status
Thread.Sleep(TimeSpan.FromSeconds(10));
Console.WriteLine(collectorSet.Status);
// Wait another moment and report the status
Thread.Sleep(TimeSpan.FromMinutes(1));
Console.WriteLine(collectorSet.Status);
The
IDataCollectorSet.Query accepts the same name and server parameters (the first two) you passed into IDataCollectorSet.Commit. Loading a data collector set this way overwrites any parameters that were already configured on the IDataCollectorSet instance.
Data collector sets run in a separate process. Pass
true to
IDataCollectorSet.start to run the set synchronously, which causes the current thread to wait for the run to complete; pass
false to return control to the current thread as soon as Windows queues the run.
If you run a data collector set asynchronously, you can use the
IDataCollectorSet.Status property to monitor the state of the run. Table 2 lists the various status enumeration values.
Table 2. DataCollectorSetStatus Enumeration Values: The table lists the values in the DataCollectorSetStatus enumeration, along with a brief description of each.
DataCollectorSetStatus Enumeration |
Description |
plaStopped |
Not running. |
plaRunning |
Collecting data. |
plaCompiling |
Performing data management and compiling data. |
plaPending |
Queued to run. Only reported by legacy operating systems. |
plaUndefined |
Unable to determine status. Usually reported by Autologgers. |
Running this code on my computer produces:
plaStopped
plaRunning
plaCompiling
The timing isn't guaranteed, so your results may vary.
You can examine the run results using the RPM.
Working with Data Collectors
 | |
Figure 10. Examining Data Collector Sets: Data collector sets contain one or more data collectors. You can view individual data collectors through the RPM. |
Data collectors are the building blocks of data collector sets. They're components that extract performance, trace, and registry data. The template we used to create the data collector sets in the preceding example has two data collectors: NT Kernel, a trace data collector, and Performance Counter, a performance data collector.
Figure 10 shows how you can use the RPM to examine data collectors visually.
Use the
IDataCollectorSet.DataCollectors property to enumerate data collectors.
// Enumerate the data collectors
foreach (IDataCollector collector
in collectorSet.DataCollectors)
{
Console.WriteLine(collector.name);
Console.WriteLine(collector.DataCollectorType);
Console.WriteLine(collector.OutputLocation);
Console.WriteLine();
}
To add new data collectors, right-click on a data collector set in the RPM and then click New --> Data Collector. The four types of data collectors shown in
Figure 11 map to interfaces in the PLA API as shown in Table 3.
 | |
Figure 11. Creating a Data Collector: Use the RPM Data Collector Wizard to add and configure data collectors in data collector sets. |
Table 3. Data Collector Types and Interfaces: The table shows how the data collector types map to interfaces in the PLA API.
Data Collector |
PLA Interface |
Performance counter |
IPerformanceCounterDataCollector |
Event trace |
ITraceDataCollector |
Configuration |
IConfigurationDataCollector |
Performance counter alert |
IAlertDataCollector |
The PLA also provides the IApiTracingDataCollector interface to collect information about Win32 calls in
Kernel32.dll,
Advapi32.dll,
Gdi32.dll, and
User32.dll.