Changes between Version 16 and Version 17 of StatsDesign


Ignore:
Timestamp:
May 8, 2015, 3:32:18 PM (3 years ago)
Author:
tomek
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • StatsDesign

    v16 v17  
    1313
    1414== Data types ==
    15 The basic concept of statistical analysis is an observation, implemented as Observation class. There are three basic types of observations: integers (represented as uint64_t), floats (represented as double) and time intervals (represented by boost::posix_time::time_duration). By default, each Observation collects only a single value. There are two way new data can be added to the Observation: addValue() is additive, i.e. it adds the new value to existing one. This is useful for using statistic as a counter, e.g. number of packets received. The second method is setValue(), which sets absolute value. This is useful for observing properties that are are observed as absolute values, e.g. size of incoming buffer. When an observation is recorded, its time stamp is stored and will be available for retrieval. For basic observations, only the timestamp of the last change is preserved.
     15The basic concept of statistical analysis is an observation, implemented as Observation class. There are four basic types of observations: integers (represented as uint64_t), floats (represented as double), time intervals (represented by boost::posix_time::time_duration) and string (represented by std::string). By default, each Observation collects only a single value. There are two way new data can be added to the Observation: addValue() is additive, i.e. it adds the new value to existing one. This is useful for using statistic as a counter, e.g. number of packets received. The second method is setValue(), which sets absolute value. This is useful for observing properties that are are observed as absolute values, e.g. size of incoming buffer. When an observation is recorded, its time stamp is stored and will be available for retrieval. For basic observations, only the timestamp of the last change is preserved.
    1616
    1717Each observation is by default able to store a single value. However, it is sometimes useful to keep multiple values of the same property, typically to observe how a given property changed over time. To avoid unlimited memory consumption growth, such a collection should be limited. There are two ways to define the limts: time based (e.g. keep samples from the last 5 minutes) and size based (e.g. keep at most 100 samples).
     
    1919{{{
    2020// Keep the packet-received statistics for the last 5 minutes
    21 StatsMgr::instance().setStorage("packet-received", time_duration(0,5,0,0));
     21StatsMgr::instance().setMaxSampleAge("packet-received", time_duration(0,5,0,0));
    2222
    2323// Keep at most 100 samples of the statistic
    24 StatsMgr::instance().setStorage("packet-size", 100);
     24StatsMgr::instance().setMaxSampleCount("packet-size", 100);
    2525}}}
     26
     27Storing more than one observation per statistic may not be available in 0.9.2.
    2628
    2729== Data collection ==
     
    3840From the user's perspective, contexts are almost transparent and are performance optimization. The only case where they are non-transparent is statistics retrieval, when the statistics are retrieved. Contexts allow to get statistics for a given context, e.g. all statistics related to subnet[0].
    3941
     42Support for contexts may not be available in 0.9.2.
     43
    4044== Performance Optimization ==
    4145Observations are kept in a map indexed by a string that contains the statistic name. This should provide sufficiently fast access time in most cases. However, in some operations that are expected to be conducted many thousands times per second (one example could be a hypothetic counter for number of parsed options), this map  access time may become non-negligible. For those cases, it will be possible to obtain Observation object pointer and use it to increase the statistic with completely omitting the search phase.
    4246
    4347{{{
    44 ObservationPtr my_stat = StatsMgr::instance().getStat("options-parsed");
     48ObservationPtr my_stat = StatsMgr::instance().getObservation("options-parsed");
    4549if (my_stat) {
    4650    my_stat.addValue(1);