There are three types of TraceWatch Counters, we start with the simplest which is the "Single Counter".
a Single Counter holds a single integer value which is zero intially and whenever a certain condition is met in a request its value is incremented by one. go to Counters Admin Page and look at the "New Visitors" counter for example:
That condition says: "if the request is from a normal visitor and the request is from a new visitor increment the New Visitors counter by one". A single counter's values can be viewed through a Single Counter View in the the Stats Page:
A List Counter holds an integer for each value of an Entity and when a certain condition is met increments the number for the current value of that entity by one. Take "Pages Counter" for instance which counts the "Page Entity" when "Visitor is Normal":
You can see a list of Entity Values of a "List Counter" and their counts through a List Counter View in Stats Page.
A Grouped Counter holds a list counter of a certain entity for every value of another entity, it's like a two dimentional list counter. For instance we keep the number of every user-agent string for a certain browser using a grouped counter by setting "Browser Entity" as the group and "User Agent Entity" as the entity:
You have two options to show a grouped counter's data on stats page. First is using a normal List Counter View to show the results for a certain group which is not very efficient because you can implement a single-group group-counter using a list counter and a condition with much less overhead unless you want to do something special (like making a dedicated stats page to show top User-Agent strings for all major browsers). Second method is using a Sub Counter View which shows results of a grouped counter for every entity value in a List Counter View as an option.
Counters divide time into Periods and stores an integer (or a list of integer in case of list counters) for each period. Currently TraceWatch has three Period Types:
|Period Type||Comments||import code format||type import name||period import tag name|
|Daily||like "2010-Jan-01" period which starts at 2010-Jan-01 00:00:00 and ends at 2010-Jan-02 00:00:00.||YYYY-MMM-DD||daily||day|
|Monthly||like "January 2010" period which starts at 2010-Jan-01 00:00:00 and ends at 2010-Feb-01 00:00:00.||YYYY-MMM||monthly||month|
|All||Has only one member which starts at a very long time ago in the past and ends now.||none||all||all|
Counter Availability (On/Off History)
As mentioned before TraceWatch stores only one integer number for each period but it also stores the exact times at which a counter was turned off or turned on.
Having this fine information TraceWatch knows that the number 54 recorded for January 26th only represents hits in 10 hours not the whole 24 hours and takes this into account when doing any averaging or other kinds of computation.
Period numbers in conjunction with the availability timestamps represents the actual hit count in a certain period.
Counters Admin Page
At the top of the page there are four buttons that affect all the counters. Start All, Stop All and Reset All does what they say. For the meaning of starting, stopping and resetting a counter see below.
If you have deleted any of the predefined TraceWatch counters the Restore Deleted Defaults button will restore them. Note that restored counters will be Stopped until you start them.
All Counters Count When
This is the global counters condition. Regardless of individual counter conditions no counter increments unless this expression is true.
Below are the operations you can perform on each counter using the buttons available for each counter.
- Stopping a counter stops it from counting. When doing any kind of averaging or estimation TraceWatch ignores the time during which a counter was stopped so it's good practice to stop all counters when the website is down for maintenance or other such situations (otherwise TraceWatch would assume your website had zero visitors during that time). You can see the Start/Stop history (aka Counter Availability) of a counter by clicking "more info" button at the bottom right corner of each counter.
- Apply Changes
- If you have changed any of the counter's settings you should click this to actually apply the changes to the counter.
- Cleanup Now
- As you'll learn later in this section, cleanup tasks are not performed immediately. By clicking this button you force TraceWatch to perform the cleanup immediately using counter's current cleanup settings. Remember, if you have changed the cleanup setting you must press the "Apply Changes" button before pressing "Cleanup Now".
- Restore Defaults
- For predefined TraceWatch counters you can click this to restore the default settings. Note that the change is immediately applied to the counter.
- Zeros a single counter and completely clears a list counter's data (like it has just started counting).
- Removes any data related to a counter and deletes the counter itself. TraceWatch's predefined counters (the counter itself not the data) can be restored using the global "Restore Deleted Defaults" button but custom counters cannot be restored after being deleted.
Counter data can become huge if you let the counters work indefinitely so TraceWatch provides means to automatically cleanup counters' data and delete old and unnecessary information.
You can ask TraceWatch to delete daily data when they are n days old or monthly data when they are n months old. These deletings happend every day (or month). For example if you specify that you want your daily data deleted when they are 10 days old
Everyday TraceWatch deletes 10 days ago's data. This operation is not performed abruptly at the beginning of the day but it's distributed throughout the day so don't be surprised to see some counters' old data deleted and some others' not in the middle of the day.
When data are deleted the Start/Stop history is also adjusted to reflect that older data are not available anymore. (see the Start/Stop under Counter Operations above)
You can also ask TraceWatch to trim data of a list counter when they become n days (or months) old. Trimming consists of removing values that are not in top m values of a list.
For example if you specify that you want your referrers monthly data trimmed to 20 rows when 3 months old
Every month TraceWatch looks at referrers of 3 months ago's referrers list and deletes those not in top 20. Like deleting, trimming tasks are not performed abruptly but are distributed.
- Active Trimming
For long period types (currently only "All Time") normal trimming is not practical. To cleanup such period types you do the active trimming.
Active trimming is having a shadow counter counting in parallel alongside the primary counter and every n days subtracting values that are not in top m in the shadow counter from the primary counter, removing rows that become zero in the primary counter and resetting the shadow counter.
For example if you specify you want your countries "All Time" data active trimmed to 10 rows every 20 days
TraceWatch runs a shadow counter alongside the countries counter which works exactly like the countries counter. Every 20 days the values in the shadow counter that are not in top 10 are subtracted from the primary counter's "All Time" list and those rows that become zero are deleted. Then the shadow counter is reset and starts working for another 20 days.
Active trimming can be applied to any period type but is more useful for long period types like "All Time" or if we have a "Quarter" period type in future. For daily and monthly data stick with the normal trimming.