![]() |
Kea
1.5.0
|
Represents a single observable characteristic (a 'statistic') More...
#include <observation.h>
Public Types | |
| enum | Type { STAT_INTEGER, STAT_FLOAT, STAT_DURATION, STAT_STRING } |
| Type of available statistics. More... | |
Public Member Functions | |
| Observation (const std::string &name, const double value) | |
| Constructor for floating point observations. More... | |
| Observation (const std::string &name, const int64_t value) | |
| Constructor for integer observations. More... | |
| Observation (const std::string &name, const StatsDuration &value) | |
| Constructor for duration observations. More... | |
| Observation (const std::string &name, const std::string &value) | |
| Constructor for string observations. More... | |
| void | addValue (const double value) |
| Records incremental floating point observation. More... | |
| void | addValue (const int64_t value) |
| Records incremental integer observation. More... | |
| void | addValue (const StatsDuration &value) |
| Records incremental duration observation. More... | |
| void | addValue (const std::string &value) |
| Records incremental string observation. More... | |
| DurationSample | getDuration () const |
| Returns observed duration sample. More... | |
| FloatSample | getFloat () const |
| Returns observed float sample. More... | |
| IntegerSample | getInteger () const |
| Returns observed integer sample. More... | |
| isc::data::ConstElementPtr | getJSON () const |
| Returns as a JSON structure. More... | |
| std::string | getName () const |
| Returns observation name. More... | |
| StringSample | getString () const |
| Returns observed string sample. More... | |
| Type | getType () const |
| Returns statistic type. More... | |
| void | reset () |
| Resets statistic. More... | |
| void | setValue (const double value) |
| Records absolute floating point observation. More... | |
| void | setValue (const int64_t value) |
| Records absolute integer observation. More... | |
| void | setValue (const StatsDuration &value) |
| Records absolute duration observation. More... | |
| void | setValue (const std::string &value) |
| Records absolute string observation. More... | |
Static Public Member Functions | |
| static std::string | typeToText (Type type) |
| Converts statistic type to string. More... | |
Represents a single observable characteristic (a 'statistic')
Currently it supports one of four types: integer (implemented as signed 64 bit integer), float (implemented as double), time duration (implemented with millisecond precision) and string. Absolute (setValue) and incremental (addValue) modes are supported. Statistic type is determined during its first use. Once type is set, any additional observations recorded must be of the same type. Attempting to set or extract information about other types will result in InvalidStateType exception.
Observation can be retrieved in one of getInteger, getFloat, getDuration, getString (appropriate type must be used) or getJSON, which is generic and can be used for all types.
Definition at line 71 of file observation.h.
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). To avoid confusion, we will support only one type of integer and only one type of floating points. Initially, these are represented by int64_t and double. If convincing use cases appear to change them to something else, we may change the underlying type.
Definition at line 82 of file observation.h.
| isc::stats::Observation::Observation | ( | const std::string & | name, |
| const int64_t | value | ||
| ) |
Constructor for integer observations.
| name | observation name |
| value | integer value observed. |
Definition at line 23 of file observation.cc.
References setValue().
Here is the call graph for this function:| isc::stats::Observation::Observation | ( | const std::string & | name, |
| const double | value | ||
| ) |
Constructor for floating point observations.
| name | observation name |
| value | floating point value observed. |
Definition at line 28 of file observation.cc.
References setValue().
Here is the call graph for this function:| isc::stats::Observation::Observation | ( | const std::string & | name, |
| const StatsDuration & | value | ||
| ) |
Constructor for duration observations.
| name | observation name |
| value | duration observed. |
Definition at line 33 of file observation.cc.
References setValue().
Here is the call graph for this function:| isc::stats::Observation::Observation | ( | const std::string & | name, |
| const std::string & | value | ||
| ) |
Constructor for string observations.
| name | observation name |
| value | string observed. |
Definition at line 38 of file observation.cc.
References setValue().
Here is the call graph for this function:| void isc::stats::Observation::addValue | ( | const double | value | ) |
Records incremental floating point observation.
| value | floating point value observed |
| InvalidStatType | if statistic is not fp |
Definition at line 48 of file observation.cc.
References getFloat(), and setValue().
Here is the call graph for this function:| void isc::stats::Observation::addValue | ( | const int64_t | value | ) |
Records incremental integer observation.
| value | integer value observed |
| InvalidStatType | if statistic is not integer |
Definition at line 43 of file observation.cc.
References getInteger(), and setValue().
Here is the call graph for this function:| void isc::stats::Observation::addValue | ( | const StatsDuration & | value | ) |
Records incremental duration observation.
| value | duration value observed |
| InvalidStatType | if statistic is not time duration |
Definition at line 53 of file observation.cc.
References getDuration(), and setValue().
Here is the call graph for this function:| void isc::stats::Observation::addValue | ( | const std::string & | value | ) |
Records incremental string observation.
| value | string value observed |
| InvalidStatType | if statistic is not a string |
Definition at line 58 of file observation.cc.
References getString(), and setValue().
Here is the call graph for this function:| DurationSample isc::stats::Observation::getDuration | ( | ) | const |
Returns observed duration sample.
| InvalidStatType | if statistic is not time duration |
Definition at line 105 of file observation.cc.
References STAT_DURATION.
Referenced by addValue(), and getJSON().
| FloatSample isc::stats::Observation::getFloat | ( | ) | const |
Returns observed float sample.
| InvalidStatType | if statistic is not fp |
Definition at line 101 of file observation.cc.
References STAT_FLOAT.
Referenced by addValue(), and getJSON().
| IntegerSample isc::stats::Observation::getInteger | ( | ) | const |
Returns observed integer sample.
| InvalidStatType | if statistic is not integer |
Definition at line 97 of file observation.cc.
References STAT_INTEGER.
Referenced by addValue(), and getJSON().
| isc::data::ConstElementPtr isc::stats::Observation::getJSON | ( | ) | const |
Returns as a JSON structure.
Definition at line 154 of file observation.cc.
References isc::data::Element::create(), isc::data::Element::createList(), isc::util::durationToText(), getDuration(), getFloat(), getInteger(), getString(), isc_throw, isc::util::ptimeToText(), STAT_DURATION, STAT_FLOAT, STAT_INTEGER, STAT_STRING, and typeToText().
Here is the call graph for this function:
|
inline |
Returns observation name.
Definition at line 201 of file observation.h.
| StringSample isc::stats::Observation::getString | ( | ) | const |
Returns observed string sample.
| InvalidStatType | if statistic is not a string |
Definition at line 109 of file observation.cc.
References STAT_STRING.
Referenced by addValue(), and getJSON().
|
inline |
| void isc::stats::Observation::reset | ( | ) |
Resets statistic.
Sets statistic to a neutral (0, 0.0 or "") value.
Definition at line 202 of file observation.cc.
References isc_throw, setValue(), STAT_DURATION, STAT_FLOAT, STAT_INTEGER, STAT_STRING, and typeToText().
Here is the call graph for this function:| void isc::stats::Observation::setValue | ( | const double | value | ) |
Records absolute floating point observation.
| value | floating point value observed |
| InvalidStatType | if statistic is not fp |
Definition at line 67 of file observation.cc.
References STAT_FLOAT.
| void isc::stats::Observation::setValue | ( | const int64_t | value | ) |
Records absolute integer observation.
| value | integer value observed |
| InvalidStatType | if statistic is not integer |
Definition at line 63 of file observation.cc.
References STAT_INTEGER.
Referenced by addValue(), Observation(), and reset().
| void isc::stats::Observation::setValue | ( | const StatsDuration & | value | ) |
Records absolute duration observation.
| value | duration value observed |
| InvalidStatType | if statistic is not time duration |
Definition at line 71 of file observation.cc.
References STAT_DURATION.
| void isc::stats::Observation::setValue | ( | const std::string & | value | ) |
Records absolute string observation.
| value | string value observed |
| InvalidStatType | if statistic is not a string |
Definition at line 75 of file observation.cc.
References STAT_STRING.
|
static |
Converts statistic type to string.
Definition at line 130 of file observation.cc.
References STAT_DURATION, STAT_FLOAT, STAT_INTEGER, and STAT_STRING.