/// @brief Defines duration resolution
///
/// Boost offers a base boost::posix_time::time_duration class, that has specific
-/// implementations: boost::posix_time::{hours,minutes,seconds,millisec,nanosec}.
-/// For statistics purposes, the most appropriate choice seems to be milliseconds
-/// precision, so we'll stick with that.
+/// implementations: boost::posix_time::{hours,minutes,seconds,millisec,microsec,
+/// nanosec}. For statistics purposes, the most appropriate choice seems to be
+/// microseconds precision, so we'll stick with that.
typedef boost::posix_time::microsec::time_duration StatsDuration;
/// @defgroup stat_samples Specifies supported observation types.
class Observation {
public:
- /// @brief type of available statistics
+ /// @brief Type of available statistics
///
/// Note that those will later be exposed using control socket. Therefore
/// an easy to understand names were chosen (integer instead of uint64).
/// @throw InvalidStatType if statistic is not integer
void addValue(uint64_t value = 1);
- /// @brief Records inremental floating point observation
+ /// @brief Records incremental floating point observation
///
/// @param value floating point value observed
/// @throw InvalidStatType if statistic is not fp
namespace isc {
namespace stats {
+/// @brief Statistics Manager class
+///
+/// StatsMgr is a singleton class that represents a subsystem that manages
+/// collection, storage and reporting of various types of statistics.
+/// It is also the intended API for both core code and hooks.
class StatsMgr : public boost::noncopyable {
public:
/// @brief Statistics Manager accessor method.
static StatsMgr& instance();
- // methods used data producers
- void addValue(const std::string& name, uint64_t value);
- void addValue(const std::string& name, double value);
- void addValue(const std::string& name, StatsDuration time);
- void addValue(const std::string& name, const std::string& value);
+ /// @defgroup producer_methods Methods are used by data producers.
+ ///
+ /// @brief The following methods are used by data producers:
+ ///
+ /// @{
+
+ /// @brief Records absolute integer observation
+ ///
+ /// @param name name of the observation
+ /// @param value integer value observed
+ /// @throw InvalidStatType if statistic is not integer
void setValue(const std::string& name, uint64_t value);
+
+ /// @brief Records absolute floating point observation
+ ///
+ /// @param name name of the observation
+ /// @param value floating point value observed
+ /// @throw InvalidStatType if statistic is not fp
void setValue(const std::string& name, double value);
+
+ /// @brief Records absolute duration observation
+ ///
+ /// @param name name of the observation
+ /// @param value duration value observed
+ /// @throw InvalidStatType if statistic is not time duration
void setValue(const std::string& name, StatsDuration value);
+
+ /// @brief Records absolute string observation
+ ///
+ /// @param name name of the observation
+ /// @param value string value observed
+ /// @throw InvalidStatType if statistic is not a string
void setValue(const std::string& name, const std::string& value);
+ /// @brief Records incremental integer observation
+ ///
+ /// @param name name of the observation
+ /// @param value integer value observed
+ /// @throw InvalidStatType if statistic is not integer
+ void addValue(const std::string& name, uint64_t value);
+
+ /// @brief Records incremental floating point observation
+ ///
+ /// @param name name of the observation
+ /// @param value floating point value observed
+ /// @throw InvalidStatType if statistic is not fp
+ void addValue(const std::string& name, double value);
+
+ /// @brief Records incremental duration observation
+ ///
+ /// @param name name of the observation
+ /// @param value duration value observed
+ /// @throw InvalidStatType if statistic is not time duration
+ void addValue(const std::string& name, StatsDuration time);
+
+ /// @brief Records incremental string observation.
+ ///
+ /// @param name name of the observation
+ /// @param value string value observed
+ /// @throw InvalidStatType if statistic is not a string
+ void addValue(const std::string& name, const std::string& value);
+
/// @brief determines whether a given statistic is kept as a single value
/// or as a number of values
///
/// setMaxSampleCount("incoming-packets", 100);
void setMaxSampleCount(const std::string& name, uint32_t max_samples);
+ /// @}
+
+ /// @defgroup consumer_methods Methods are used by data consumers.
+ ///
+ /// @brief The following methods are used by data consumers:
+ ///
+ /// @{
+
/// @brief Resets specified statistic.
///
/// This is a convenience function and is equivalent to setValue(name,
/// @return JSON structures representing all statistics
isc::data::ConstElementPtr getAll() const;
+ /// @}
+
/// @brief Returns an observation
///
/// Used in testing only. Production code should use @ref get() method.
private:
+ /// @brief Sets a given statistic to specified value (internal version)
+ ///
+ /// This template method sets statistic identified by name to a value
+ /// specified by value. This internal method is used by public @ref setValue
+ /// methods.
+ ///
+ /// @tparam DataType one of uint64_t, double DurationStat or string
+ /// @param name name of the statistic
+ /// @param value specified statistic will be set to this value
+ /// @throw InvalidStatType is statistic exists and has a different type.
template<typename DataType>
void setValueInternal(const std::string& name, DataType value) {
ObservationPtr stat = getObservation(name);
}
}
+ /// @brief Adds specified value to a given statistic (internal version)
+ ///
+ /// This template method adds specified value to a given statistic (identified
+ /// by name to a value). This internal method is used by public @ref setValue
+ /// methods.
+ ///
+ /// @tparam DataType one of uint64_t, double DurationStat or string
+ /// @param name name of the statistic
+ /// @param value specified statistic will be set to this value
+ /// @throw InvalidStatType is statistic exists and has a different type.
template<typename DataType>
void addValueInternal(const std::string& name, DataType value) {
ObservationPtr existing = getObservation(name);