14#include <boost/noncopyable.hpp> 
   15#include <boost/scoped_ptr.hpp> 
   65class StatsMgr : 
public boost::noncopyable {
 
   82    void setValue(
const std::string& name, 
const int64_t value);
 
   96    void setValue(
const std::string& name, 
const double value);
 
  110    void setValue(
const std::string& name, 
const std::string& value);
 
  117    void addValue(
const std::string& name, 
const int64_t value);
 
  131    void addValue(
const std::string& name, 
const double value);
 
  145    void addValue(
const std::string& name, 
const std::string& value);
 
  226    bool reset(
const std::string& name);
 
  232    bool del(
const std::string& name);
 
  245    size_t getSize(
const std::string& name) 
const;
 
  250    size_t count() 
const;
 
  297    template<
typename Type>
 
  298    static std::string 
generateName(
const std::string& context, Type index,
 
  299                                    const std::string& stat_name) {
 
  300        std::stringstream name;
 
  301        name << context << 
"[" << index << 
"]." << stat_name;
 
 
  506    template<
typename DataType>
 
  511            stat->setValue(value);
 
 
  530    template<
typename DataType>
 
  543            existing->addValue(value);
 
 
  577    bool deleteObservation(
const std::string& name);
 
  587    bool deleteObservationInternal(
const std::string& name);
 
  598    bool setMaxSampleAgeInternal(
const std::string& name, 
const StatsDuration& duration);
 
  609    bool setMaxSampleCountInternal(
const std::string& name, uint32_t max_samples);
 
  618    void setMaxSampleAgeAllInternal(
const StatsDuration& duration);
 
  627    void setMaxSampleCountAllInternal(uint32_t max_samples);
 
  636    void setMaxSampleAgeDefaultInternal(
const StatsDuration& duration);
 
  644    void setMaxSampleCountDefaultInternal(uint32_t max_samples);
 
  661    uint32_t getMaxSampleCountDefaultInternal() 
const;
 
  671    bool resetInternal(
const std::string& name);
 
  681    bool delInternal(
const std::string& name);
 
  688    void resetAllInternal();
 
  695    void removeAllInternal();
 
  705    size_t getSizeInternal(
const std::string& name) 
const;
 
  714    size_t countInternal() 
const;
 
  750                            std::string& reason);
 
  772                                std::string& reason);
 
  792                                  uint32_t& max_samples,
 
  793                                  std::string& reason);
 
  799    const boost::scoped_ptr<std::mutex> mutex_;
 
 
Represents a single observable characteristic (a 'statistic')
Statistics Manager class.
ObservationPtr getObservation(const std::string &name) const
Returns an observation.
ObservationPtr getObservationInternal(const std::string &name) const
Returns an observation in a thread safe context.
static StatsMgr & instance()
Statistics Manager accessor method.
void addObservationInternal(const ObservationPtr &stat)
Adds a new observation in a thread safe context.
void addValueInternal(const std::string &name, DataType value)
Adds specified value to a given statistic (internal version).
void addObservation(const ObservationPtr &stat)
Adds a new observation.
void setValueInternal(const std::string &name, DataType value)
Sets a given statistic to specified value (internal version).
static std::string generateName(const std::string &context, Type index, const std::string &stat_name)
Generates statistic name in a given context.
isc::data::ConstElementPtr statisticSetMaxSampleCountAllHandler(const isc::data::ConstElementPtr ¶ms)
Handles statistic-sample-count-set-all command.
static isc::data::ConstElementPtr statisticResetHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-reset command.
static isc::data::ConstElementPtr statisticGetAllHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-get-all command.
static isc::data::ConstElementPtr statisticRemoveHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-remove command.
static isc::data::ConstElementPtr statisticGetHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-get command.
isc::data::ConstElementPtr statisticSetMaxSampleAgeAllHandler(const isc::data::ConstElementPtr ¶ms)
Handles statistic-sample-age-set-all command.
static isc::data::ConstElementPtr statisticResetAllHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-reset-all command.
static isc::data::ConstElementPtr statisticSetMaxSampleAgeHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-sample-age-set command.
static isc::data::ConstElementPtr statisticRemoveAllHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-remove-all command.
static isc::data::ConstElementPtr statisticSetMaxSampleCountHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-sample-count-set command.
bool reset(const std::string &name)
Resets specified statistic.
void removeAll()
Removes all collected statistics.
void resetAll()
Resets all collected statistics back to zero.
bool del(const std::string &name)
Removes specified statistic.
size_t count() const
Returns number of available statistics.
isc::data::ConstElementPtr getAll() const
Returns all statistics as a JSON structure.
size_t getSize(const std::string &name) const
Returns size of specified statistic.
isc::data::ConstElementPtr get(const std::string &name) const
Returns a single statistic as a JSON structure.
void setMaxSampleCountDefault(uint32_t max_samples)
Set default count limit.
bool setMaxSampleCount(const std::string &name, uint32_t max_samples)
Determines how many samples of a given statistic should be kept.
uint32_t getMaxSampleCountDefault() const
Get default count limit.
void setValue(const std::string &name, const int64_t value)
Records absolute integer observation.
bool setMaxSampleAge(const std::string &name, const StatsDuration &duration)
Determines maximum age of samples.
const StatsDuration & getMaxSampleAgeDefault() const
Get default duration limit.
void setMaxSampleAgeAll(const StatsDuration &duration)
Set duration limit for all collected statistics.
void setMaxSampleCountAll(uint32_t max_samples)
Set count limit for all collected statistics.
void addValue(const std::string &name, const int64_t value)
Records incremental integer observation.
void setMaxSampleAgeDefault(const StatsDuration &duration)
Set default duration limit.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Observation > ObservationPtr
Observation pointer.
boost::shared_ptr< StatContext > StatContextPtr
Pointer to the statistics context.
std::chrono::system_clock::duration StatsDuration
Defines duration type.
boost::multiprecision::checked_int128_t int128_t
Defines the logger used by the top-level component of kea-lfc.