12 #include <boost/shared_ptr.hpp> 46 return ((std::chrono::duration_cast<std::chrono::seconds>(dur)).count());
59 typedef std::pair<double, SampleClock::time_point>
FloatSample;
65 typedef std::pair<std::string, SampleClock::time_point>
StringSample;
106 Observation(
const std::string& name,
const int64_t value);
112 Observation(
const std::string& name,
const double value);
118 Observation(
const std::string& name,
const StatsDuration& value);
124 Observation(
const std::string& name,
const std::string& value);
141 void setMaxSampleAge(
const StatsDuration& duration);
155 void setMaxSampleCount(uint32_t max_samples);
160 static void setMaxSampleAgeDefault(
const StatsDuration& duration);
166 static void setMaxSampleCountDefault(uint32_t max_samples);
171 static const StatsDuration& getMaxSampleAgeDefault();
177 static uint32_t getMaxSampleCountDefault();
185 void setValue(
const int64_t value);
191 void setValue(
const double value);
197 void setValue(
const StatsDuration& value);
203 void setValue(
const std::string& value);
209 void addValue(
const int64_t value);
215 void addValue(
const double value);
221 void addValue(
const StatsDuration& value);
227 void addValue(
const std::string& value);
232 size_t getSize()
const;
237 std::pair<bool, StatsDuration> getMaxSampleAge()
const;
242 std::pair<bool, uint32_t> getMaxSampleCount()
const;
259 IntegerSample getInteger()
const;
264 FloatSample getFloat()
const;
269 DurationSample getDuration()
const;
274 StringSample getString()
const;
279 std::list<IntegerSample> getIntegers()
const;
284 std::list<FloatSample> getFloats()
const;
289 std::list<DurationSample> getDurations()
const;
294 std::list<StringSample> getStrings()
const;
302 static std::string typeToText(
Type type);
320 template<
typename StorageType>
321 size_t getSizeInternal(StorageType& storage,
Type exp_type)
const;
335 template<
typename SampleType,
typename StorageType>
336 void setValueInternal(SampleType value, StorageType& storage,
347 template<
typename SampleType,
typename Storage>
348 SampleType getValueInternal(Storage& storage,
Type exp_type)
const;
358 template<
typename SampleType,
typename Storage>
359 std::list<SampleType> getValuesInternal(Storage& storage,
360 Type exp_type)
const;
368 template<
typename StorageType>
369 void setMaxSampleAgeInternal(StorageType& storage,
370 const StatsDuration& duration,
Type exp_type);
378 template<
typename StorageType>
379 void setMaxSampleCountInternal(StorageType& storage,
380 uint32_t max_samples,
Type exp_type);
395 std::pair<bool, uint32_t> max_sample_count_;
401 static std::pair<bool, uint32_t> default_max_sample_count_;
410 std::pair<bool, StatsDuration> max_sample_age_;
416 static std::pair<bool, StatsDuration> default_max_sample_age_;
426 std::list<IntegerSample> integer_samples_;
429 std::list<FloatSample> float_samples_;
432 std::list<DurationSample> duration_samples_;
435 std::list<StringSample> string_samples_;
445 #endif // OBSERVATION_H this statistic is unsigned 64-bit integer value
std::pair< double, SampleClock::time_point > FloatSample
Float (implemented as double precision)
InvalidStatType(const char *file, size_t line, const char *what)
std::chrono::system_clock SampleClock
Define clock type.
this statistic is a floating point value
Type getType() const
Returns statistic type.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
std::chrono::system_clock::duration StatsDuration
Defines duration type.
std::pair< std::string, SampleClock::time_point > StringSample
String.
boost::shared_ptr< const Element > ConstElementPtr
std::pair< int64_t, SampleClock::time_point > IntegerSample
Integer (implemented as signed 64-bit integer)
this statistic represents time duration
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-lfc.
std::string getName() const
Returns observation name.
Represents a single observable characteristic (a 'statistic')
Type
Type of available statistics.
boost::shared_ptr< Observation > ObservationPtr
Observation pointer.
Exception thrown if invalid statistic type is used.
std::pair< StatsDuration, SampleClock::time_point > DurationSample
Time Duration.
long toSeconds(const StatsDuration &dur)
Returns the number of seconds in a duration.