
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Implementing Performance Counters That Require a Base Counter
|
469
8.12 Implementing Performance Counters That
Require a Base Counter
Problem
You need to use some of the more advanced performance counters to accurately
track information about your application. The performance counters exist as two
counters used together. The first counter is the main counter, which is divided by the
second counter, called the base counter. Essentially, the first counter is the numera-
tor and the second counter is the denominator; the custom counter reports the result
of this division operation. The main counter is used in tandem with its base counter
type to calculate, for example, the average amount of time it takes for an action (e.g.,
connecting to a server) to complete or the average number of actions that occur dur-
ing a single process (e.g., database timeouts).
Solution
Create a complex performance counter, which is used in tandem with the base
counter type to calculate, for example, the average amount of time it takes for an
action to complete or the average number of actions that occur during a single pro-
cess. Use the
CreateComplexCounter method shown in Example 8-5 to create a com-
plex custom counter.
Example 8-5. Creating a complex counter
public void CreateComplexCounter(string counterName, ...