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);
197 void setValue(
const StatsDuration& value);
203 void setValue(
const std::string& value);
221 void addValue(
const StatsDuration& value);
227 void addValue(
const std::string& value);
284 std::list<FloatSample>
getFloats()
const;
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
void addValue(const int64_t value)
Records incremental integer observation.
this statistic is unsigned 64-bit integer value
std::pair< double, SampleClock::time_point > FloatSample
Float (implemented as double precision)
this statistic represents a string
InvalidStatType(const char *file, size_t line, const char *what)
std::pair< bool, uint32_t > getMaxSampleCount() const
Returns both values of max_sample_count_ of statistic.
Type getType() const
Returns statistic type.
static void setMaxSampleAgeDefault(const StatsDuration &duration)
Determines default maximum age of samples.
std::chrono::system_clock SampleClock
Define clock type.
std::list< FloatSample > getFloats() const
Returns observed float samples.
DurationSample getDuration() const
Returns observed duration sample.
static uint32_t getMaxSampleCountDefault()
Get default maximum count of samples.
this statistic is a floating point value
Observation(const std::string &name, const int64_t value)
Constructor for integer observations.
std::list< IntegerSample > getIntegers() const
Returns observed integer samples.
std::chrono::system_clock::duration StatsDuration
Defines duration type.
size_t getSize() const
Returns size of observed storage.
void reset()
Resets statistic.
isc::data::ConstElementPtr getJSON() const
Returns as a JSON structure.
std::pair< std::string, SampleClock::time_point > StringSample
String.
boost::shared_ptr< const Element > ConstElementPtr
IntegerSample getInteger() const
Returns observed integer sample.
std::pair< int64_t, SampleClock::time_point > IntegerSample
Integer (implemented as signed 64-bit integer)
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
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-dhcp-ddns.
static const StatsDuration & getMaxSampleAgeDefault()
Get default maximum age of samples.
FloatSample getFloat() const
Returns observed float sample.
static void setMaxSampleCountDefault(uint32_t max_samples)
Determines default maximum count of samples.
std::list< DurationSample > getDurations() const
Returns observed duration samples.
std::pair< bool, StatsDuration > getMaxSampleAge() const
Returns both values of max_sample_age_ of statistic.
std::string getName() const
Returns observation name.
void setValue(const int64_t value)
@
std::list< StringSample > getStrings() const
Returns observed string samples.
Represents a single observable characteristic (a 'statistic')
StringSample getString() const
Returns observed string sample.
void setMaxSampleAge(const StatsDuration &duration)
Determines maximum age of samples.
Type
Type of available statistics.
static std::string typeToText(Type type)
Converts statistic type to string.
void setMaxSampleCount(uint32_t max_samples)
Determines how many samples of a given statistic should be kept.
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.