Skip to content

Factories, Categories, Counters

ikopylov edited this page Nov 27, 2017 · 4 revisions

Factories

Creating counters always started from creating counter factory. Performance counters library support following factories out of the box:

  • NullCounterFactory - factory for degenerated counters (you can use it when you currently don't need counters);
  • InternalCounterFactory - factory for counters, which values are available only inside application;
  • WinCounterFactory - wrapper for Windows Performance Counters;
  • NetCounterFactory - factory for counters, which values are distributed to remote WCF service;
  • GraphiteCounterFactory - factory for counters, which values are distributed to remote Graphite/Carbon server.

Categories

Category is a group of counters. Category can have any number of child categories (so we have a tree of categories).

Sample hierarchy:

  • MyProgram
    • NetworkModule (MyProgram.NetworkModule)
    • StorageModule
      • MSSQLServer (MyProgram.StorageModule.MSSQLServer)
      • MySQL (MyProgram.StorageModule.MySQL)
    • ProcessingModule (MyProgram.ProcessingModule)

There are 3 types of categories supported by library:

  1. EmptyCategory - intermediate category. Can't contain any counter;
  2. SingleInstanceCategory - category that directly contains counters;
  3. MultiInstanceCategory - category that have multiple instances of every counter. To use this category you should also write InstanceInMultiInstanceCategory. Instance can be created and removed in runtime. Examples: in NetworkModule you can track parameters per connection (every connection - separate instance).

You can find how to use this categories here and here.

Counters

The library support following types of counters:

  • NumberOfItemsCounter - contains simple numeric value (example: measure umber of received requests);
  • OperationsPerSecondCounter - tracks the number of operations executed per second (example: measure performance of your code);
  • AverageCountCounter - contains the average of registered values (example: measure average size of queue);
  • AverageTimeCounter - tracks the average execution time of some process (example: measure average execution time of your functions);
  • MomentTimeCounter - contains latest registered time interval (example: fixate time of some process that executing only once);
  • ElapsedTimeCounter - tracks the time since counter was created or reseted (example: measure the total execution time of your application);
  • DeltaCounter - shows the change in the measured attribute between the two most recent sample intervals (example: measure changes in processing rate).

Again, you can find examples here and here.

Clone this wiki locally