]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1005] Checkpoint: updated stats lib
authorFrancis Dupont <fdupont@isc.org>
Sun, 5 Apr 2020 11:22:19 +0000 (13:22 +0200)
committerFrancis Dupont <fdupont@isc.org>
Tue, 14 Apr 2020 18:31:35 +0000 (20:31 +0200)
doc/examples/kea4/all-keys.json
doc/examples/kea6/all-keys.json
src/bin/dhcp4/json_config_parser.cc
src/bin/dhcp6/json_config_parser.cc
src/lib/dhcpsrv/parsers/simple_parser4.cc
src/lib/dhcpsrv/parsers/simple_parser6.cc
src/lib/stats/observation.cc
src/lib/stats/observation.h
src/lib/stats/stats_mgr.cc
src/lib/stats/stats_mgr.h

index bb4e43d7b76beea1b152fef3b1b94143b48a28d2..cc780a006890938a33dc5737051d17e2dd66a688 100644 (file)
         // information) with each lease.
         "store-extended-info": true,
 
+       // Statistics keep some samples per observation point.
+       // There are two default values: maximum count and maximum age.
+       // Set the maximum count to zero disables it.
+       "statistic-default-sample-count": 0,
+
+       // When the maximum count the maximum age (in seconds) applies.
+       "statistic-default-sample-age": 60,
+
         // Governs how the Kea DHCPv4 server should deal with the invalid
         // data received from the client.
         "sanity-checks": {
index 8d57b112d9d3ade5a2870a660317c170c2eed91a..36254f026b3a19d34c50a97f9c93e586ab216586 100644 (file)
         // information) with each lease.
         "store-extended-info": true,
 
+       // Statistics keep some samples per observation point.
+       // There are two default values: maximum count and maximum age.
+       // Set the maximum count to zero disables it.
+       "statistic-default-sample-count": 0,
+
+       // When the maximum count the maximum age (in seconds) applies.
+       "statistic-default-sample-age": 60,
+
         // Governs how the Kea DHCPv6 server should deal with the invalid
         // data received from the client.
         "sanity-checks": {
index df96fcfc654e2c6839f57c94f122be9c660335b2..0cec538b4f1de445c15ff9476886ff1fc0a44f81 100644 (file)
@@ -576,7 +576,9 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
                  (config_pair.first == "ddns-replace-client-name") ||
                  (config_pair.first == "ddns-generated-prefix") ||
                  (config_pair.first == "ddns-qualifying-suffix") ||
-                 (config_pair.first == "store-extended-info")) {
+                 (config_pair.first == "store-extended-info") ||
+                 (config_pair.first == "statistic-default-sample-count") ||
+                 (config_pair.first == "statistic-default-sample-age")) {
                 CfgMgr::instance().getStagingCfg()->addConfiguredGlobal(config_pair.first,
                                                                         config_pair.second);
                 continue;
index 5bc7244d70f29063e75dad9391149b1622017e4f..7ee22b648af50ce990ecb7ab5f7be388aaf6f9f5 100644 (file)
@@ -695,7 +695,9 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
                  (config_pair.first == "ddns-replace-client-name") ||
                  (config_pair.first == "ddns-generated-prefix") ||
                  (config_pair.first == "ddns-qualifying-suffix") ||
-                 (config_pair.first == "store-extended-info")) {
+                 (config_pair.first == "store-extended-info") ||
+                 (config_pair.first == "statistic-default-sample-count") ||
+                 (config_pair.first == "statistic-default-sample-age")) {
                 CfgMgr::instance().getStagingCfg()->addConfiguredGlobal(config_pair.first,
                                                                         config_pair.second);
                 continue;
index 5e7e4189dfd879991264986d277319ff8e1ccefc..0b38c7c0fb15258ed71395d3b224d7d9fee7a825 100644 (file)
@@ -36,54 +36,56 @@ namespace dhcp {
 /// list and map types for entries.
 /// Order follows global_param rule in bison grammar.
 const SimpleKeywords SimpleParser4::GLOBAL4_PARAMETERS = {
-    { "valid-lifetime",               Element::integer },
-    { "min-valid-lifetime",           Element::integer },
-    { "max-valid-lifetime",           Element::integer },
-    { "renew-timer",                  Element::integer },
-    { "rebind-timer",                 Element::integer },
-    { "decline-probation-period",     Element::integer },
-    { "subnet4",                      Element::list },
-    { "shared-networks",              Element::list },
-    { "interfaces-config",            Element::map },
-    { "lease-database",               Element::map },
-    { "hosts-database",               Element::map },
-    { "hosts-databases",              Element::list },
-    { "host-reservation-identifiers", Element::list },
-    { "client-classes",               Element::list },
-    { "option-def",                   Element::list },
-    { "option-data",                  Element::list },
-    { "hooks-libraries",              Element::list },
-    { "expired-leases-processing",    Element::map },
-    { "dhcp4o6-port",                 Element::integer },
-    { "control-socket",               Element::map },
-    { "dhcp-queue-control",           Element::map },
-    { "dhcp-ddns",                    Element::map },
-    { "echo-client-id",               Element::boolean },
-    { "match-client-id",              Element::boolean },
-    { "authoritative",                Element::boolean },
-    { "next-server",                  Element::string },
-    { "server-hostname",              Element::string },
-    { "boot-file-name",               Element::string },
-    { "user-context",                 Element::map },
-    { "comment",                      Element::string },
-    { "sanity-checks",                Element::map },
-    { "reservations",                 Element::list },
-    { "config-control",               Element::map },
-    { "server-tag",                   Element::string },
-    { "reservation-mode",             Element::string },
-    { "calculate-tee-times",          Element::boolean },
-    { "t1-percent",                   Element::real },
-    { "t2-percent",                   Element::real },
-    { "loggers",                      Element::list },
-    { "hostname-char-set",            Element::string },
-    { "hostname-char-replacement",    Element::string },
-    { "ddns-send-updates",            Element::boolean },
-    { "ddns-override-no-update",      Element::boolean },
-    { "ddns-override-client-update",  Element::boolean },
-    { "ddns-replace-client-name",     Element::string },
-    { "ddns-generated-prefix",        Element::string },
-    { "ddns-qualifying-suffix",       Element::string },
-    { "store-extended-info",          Element::boolean }
+    { "valid-lifetime",                 Element::integer },
+    { "min-valid-lifetime",             Element::integer },
+    { "max-valid-lifetime",             Element::integer },
+    { "renew-timer",                    Element::integer },
+    { "rebind-timer",                   Element::integer },
+    { "decline-probation-period",       Element::integer },
+    { "subnet4",                        Element::list },
+    { "shared-networks",                Element::list },
+    { "interfaces-config",              Element::map },
+    { "lease-database",                 Element::map },
+    { "hosts-database",                 Element::map },
+    { "hosts-databases",                Element::list },
+    { "host-reservation-identifiers",   Element::list },
+    { "client-classes",                 Element::list },
+    { "option-def",                     Element::list },
+    { "option-data",                    Element::list },
+    { "hooks-libraries",                Element::list },
+    { "expired-leases-processing",      Element::map },
+    { "dhcp4o6-port",                   Element::integer },
+    { "control-socket",                 Element::map },
+    { "dhcp-queue-control",             Element::map },
+    { "dhcp-ddns",                      Element::map },
+    { "echo-client-id",                 Element::boolean },
+    { "match-client-id",                Element::boolean },
+    { "authoritative",                  Element::boolean },
+    { "next-server",                    Element::string },
+    { "server-hostname",                Element::string },
+    { "boot-file-name",                 Element::string },
+    { "user-context",                   Element::map },
+    { "comment",                        Element::string },
+    { "sanity-checks",                  Element::map },
+    { "reservations",                   Element::list },
+    { "config-control",                 Element::map },
+    { "server-tag",                     Element::string },
+    { "reservation-mode",               Element::string },
+    { "calculate-tee-times",            Element::boolean },
+    { "t1-percent",                     Element::real },
+    { "t2-percent",                     Element::real },
+    { "loggers",                        Element::list },
+    { "hostname-char-set",              Element::string },
+    { "hostname-char-replacement",      Element::string },
+    { "ddns-send-updates",              Element::boolean },
+    { "ddns-override-no-update",        Element::boolean },
+    { "ddns-override-client-update",    Element::boolean },
+    { "ddns-replace-client-name",       Element::string },
+    { "ddns-generated-prefix",          Element::string },
+    { "ddns-qualifying-suffix",         Element::string },
+    { "store-extended-info",            Element::boolean },
+    { "statistic-default-sample-count", Element::integer },
+    { "statistic-default-sample-age",   Element::integer }
 };
 
 /// @brief This table defines default global values for DHCPv4
@@ -114,7 +116,9 @@ const SimpleDefaults SimpleParser4::GLOBAL4_DEFAULTS = {
     { "ddns-qualifying-suffix",         Element::string,  "" },
     { "hostname-char-set",              Element::string,  "[^A-Za-z0-9.-]" },
     { "hostname-char-replacement",      Element::string,  "" },
-    { "store-extended-info",            Element::boolean, "false" }
+    { "store-extended-info",            Element::boolean, "false" },
+    { "statistic-default-sample-count", Element::integer, "20" },
+    { "statistic-default-sample-age",   Element::integer, "0" }
 };
 
 /// @brief This table defines all option definition parameters.
index c2a66735dc0233308233f2271cf91c6d94fab0b2..78f19ab9408a1bf9329dfe42d08654fee9109c0e 100644 (file)
@@ -35,55 +35,57 @@ namespace dhcp {
 /// list and map types for entries.
 /// Order follows global_param rule in bison grammar.
 const SimpleKeywords SimpleParser6::GLOBAL6_PARAMETERS = {
-    { "data-directory",               Element::string },
-    { "preferred-lifetime",           Element::integer },
-    { "min-preferred-lifetime",       Element::integer },
-    { "max-preferred-lifetime",       Element::integer },
-    { "valid-lifetime",               Element::integer },
-    { "min-valid-lifetime",           Element::integer },
-    { "max-valid-lifetime",           Element::integer },
-    { "renew-timer",                  Element::integer },
-    { "rebind-timer",                 Element::integer },
-    { "decline-probation-period",     Element::integer },
-    { "subnet6",                      Element::list },
-    { "shared-networks",              Element::list },
-    { "interfaces-config",            Element::map },
-    { "lease-database",               Element::map },
-    { "hosts-database",               Element::map },
-    { "hosts-databases",              Element::list },
-    { "mac-sources",                  Element::list },
-    { "relay-supplied-options",       Element::list },
-    { "host-reservation-identifiers", Element::list },
-    { "client-classes",               Element::list },
-    { "option-def",                   Element::list },
-    { "option-data",                  Element::list },
-    { "hooks-libraries",              Element::list },
-    { "expired-leases-processing",    Element::map },
-    { "server-id",                    Element::map },
-    { "dhcp4o6-port",                 Element::integer },
-    { "control-socket",               Element::map },
-    { "dhcp-queue-control",           Element::map },
-    { "dhcp-ddns",                    Element::map },
-    { "user-context",                 Element::map },
-    { "comment",                      Element::string },
-    { "sanity-checks",                Element::map },
-    { "reservations",                 Element::list },
-    { "config-control",               Element::map },
-    { "server-tag",                   Element::string },
-    { "reservation-mode",             Element::string },
-    { "calculate-tee-times",          Element::boolean },
-    { "t1-percent",                   Element::real },
-    { "t2-percent",                   Element::real },
-    { "loggers",                      Element::list },
-    { "hostname-char-set",            Element::string },
-    { "hostname-char-replacement",    Element::string },
-    { "ddns-send-updates",            Element::boolean },
-    { "ddns-override-no-update",      Element::boolean },
-    { "ddns-override-client-update",  Element::boolean },
-    { "ddns-replace-client-name",     Element::string },
-    { "ddns-generated-prefix",        Element::string },
-    { "ddns-qualifying-suffix",       Element::string },
-    { "store-extended-info",          Element::boolean }
+    { "data-directory",                 Element::string },
+    { "preferred-lifetime",             Element::integer },
+    { "min-preferred-lifetime",         Element::integer },
+    { "max-preferred-lifetime",         Element::integer },
+    { "valid-lifetime",                 Element::integer },
+    { "min-valid-lifetime",             Element::integer },
+    { "max-valid-lifetime",             Element::integer },
+    { "renew-timer",                    Element::integer },
+    { "rebind-timer",                   Element::integer },
+    { "decline-probation-period",       Element::integer },
+    { "subnet6",                        Element::list },
+    { "shared-networks",                Element::list },
+    { "interfaces-config",              Element::map },
+    { "lease-database",                 Element::map },
+    { "hosts-database",                 Element::map },
+    { "hosts-databases",                Element::list },
+    { "mac-sources",                    Element::list },
+    { "relay-supplied-options",         Element::list },
+    { "host-reservation-identifiers",   Element::list },
+    { "client-classes",                 Element::list },
+    { "option-def",                     Element::list },
+    { "option-data",                    Element::list },
+    { "hooks-libraries",                Element::list },
+    { "expired-leases-processing",      Element::map },
+    { "server-id",                      Element::map },
+    { "dhcp4o6-port",                   Element::integer },
+    { "control-socket",                 Element::map },
+    { "dhcp-queue-control",             Element::map },
+    { "dhcp-ddns",                      Element::map },
+    { "user-context",                   Element::map },
+    { "comment",                        Element::string },
+    { "sanity-checks",                  Element::map },
+    { "reservations",                   Element::list },
+    { "config-control",                 Element::map },
+    { "server-tag",                     Element::string },
+    { "reservation-mode",               Element::string },
+    { "calculate-tee-times",            Element::boolean },
+    { "t1-percent",                     Element::real },
+    { "t2-percent",                     Element::real },
+    { "loggers",                        Element::list },
+    { "hostname-char-set",              Element::string },
+    { "hostname-char-replacement",      Element::string },
+    { "ddns-send-updates",              Element::boolean },
+    { "ddns-override-no-update",        Element::boolean },
+    { "ddns-override-client-update",    Element::boolean },
+    { "ddns-replace-client-name",       Element::string },
+    { "ddns-generated-prefix",          Element::string },
+    { "ddns-qualifying-suffix",         Element::string },
+    { "store-extended-info",            Element::boolean },
+    { "statistic-default-sample-count", Element::integer },
+    { "statistic-default-sample-age",   Element::integer }
 };
 
 /// @brief This table defines default global values for DHCPv6
@@ -106,11 +108,12 @@ const SimpleDefaults SimpleParser6::GLOBAL6_DEFAULTS = {
     { "ddns-override-client-update",    Element::boolean, "false" },
     { "ddns-replace-client-name",       Element::string,  "never" },
     { "ddns-generated-prefix",          Element::string,  "myhost" },
-    { "ddns-qualifying-suffix",         Element::string,   "" },
-    { "hostname-char-set",              Element::string,   "[^A-Za-z0-9.-]" },
-    { "hostname-char-replacement",      Element::string,   "" },
-    { "store-extended-info",            Element::boolean,  "false" }
-
+    { "ddns-qualifying-suffix",         Element::string,  "" },
+    { "hostname-char-set",              Element::string,  "[^A-Za-z0-9.-]" },
+    { "hostname-char-replacement",      Element::string,  "" },
+    { "store-extended-info",            Element::boolean, "false" },
+    { "statistic-default-sample-count", Element::integer, "20" },
+    { "statistic-default-sample-age",   Element::integer, "0" }
 };
 
 /// @brief This table defines all option definition parameters.
index 3253196aaf785b047083cee3184713c32218f401..926feff85f11d39680ce4368822a3f4f54a5ed2a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2020 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -20,23 +20,38 @@ using namespace boost::posix_time;
 namespace isc {
 namespace stats {
 
+std::pair<bool, uint32_t>
+Observation::default_max_sample_count_ = std::make_pair(true, 20);
+
+std::pair<bool, StatsDuration>
+Observation::default_max_sample_age_ =
+    std::make_pair(false, time_duration(0, 0, 0, 0));
+
 Observation::Observation(const std::string& name, const int64_t value) :
-    name_(name), type_(STAT_INTEGER) {
+    name_(name), type_(STAT_INTEGER),
+    max_sample_count_(default_max_sample_count_),
+    max_sample_age_(default_max_sample_age_) {
     setValue(value);
 }
 
 Observation::Observation(const std::string& name, const double value) :
-    name_(name), type_(STAT_FLOAT) {
+    name_(name), type_(STAT_FLOAT),
+    max_sample_count_(default_max_sample_count_),
+    max_sample_age_(default_max_sample_age_) {
     setValue(value);
 }
 
 Observation::Observation(const std::string& name, const StatsDuration& value) :
-    name_(name), type_(STAT_DURATION) {
+    name_(name), type_(STAT_DURATION),
+    max_sample_count_(default_max_sample_count_),
+    max_sample_age_(default_max_sample_age_) {
     setValue(value);
 }
 
 Observation::Observation(const std::string& name, const std::string& value) :
-    name_(name), type_(STAT_STRING) {
+    name_(name), type_(STAT_STRING),
+    max_sample_count_(default_max_sample_count_),
+    max_sample_age_(default_max_sample_age_) {
     setValue(value);
 }
 
@@ -306,6 +321,7 @@ void Observation::setMaxSampleCountInternal(StorageType& storage,
                   << typeToText(exp_type) << ", but the actual type is "
                   << typeToText(type_));
     }
+    // Should we refuse the max_samples = 0 value here?
     // setting new value of max_sample_count_
     max_sample_count_.first = true;
     max_sample_count_.second = max_samples;
@@ -318,6 +334,37 @@ void Observation::setMaxSampleCountInternal(StorageType& storage,
     }
 }
 
+void Observation::setMaxSampleAgeDefault(const StatsDuration& duration) {
+    // setting new value of default_max_sample_age_
+    default_max_sample_age_.second = duration;
+}
+
+void Observation::setMaxSampleCountDefault(uint32_t max_samples) {
+    if (max_samples == 0) {
+        // deactivating the default_max_sample_count_ limit
+        default_max_sample_count_.first = false;
+        default_max_sample_age_.first = true;
+    } else {
+        // setting new value of default_max_sample_count_
+        default_max_sample_count_.second = max_samples;
+        // deactivating the default_max_sample_age_ limit
+        default_max_sample_age_.first = false;
+        default_max_sample_count_.first = true;
+    }
+}
+
+const StatsDuration& Observation::getMaxSampleAgeDefault() {
+    return (default_max_sample_age_.second);
+}
+
+uint32_t Observation::getMaxSampleCountDefault() {
+    if (default_max_sample_count_.first) {
+        return (default_max_sample_count_.second);
+    } else {
+        return (0);
+    }
+}
+
 std::string Observation::typeToText(Type type) {
     std::stringstream tmp;
     switch (type) {
@@ -456,5 +503,5 @@ void Observation::reset() {
     };
 }
 
-};
-};
+} // end of namespace stats
+} // end of namespace isc
index d979500554822142083d3eed96b6399e0ed3fbcd..bfecbeb57a24639b46f601d84106c16fc1c76389 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2020 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -68,7 +68,7 @@ typedef std::pair<std::string, boost::posix_time::ptime> StringSample;
 ///
 /// Since Kea 1.6 multiple samples are stored for the same observation.
 class Observation {
- public:
+public:
 
     /// @brief Type of available statistics
     ///
@@ -140,6 +140,30 @@ class Observation {
     /// setMaxSampleCount(100);
     void setMaxSampleCount(uint32_t max_samples);
 
+    /// @brief Determines default maximum age of samples.
+    ///
+    /// @param duration determines default maximum age of samples.
+    static void setMaxSampleAgeDefault(const StatsDuration& duration);
+
+    /// @brief Determines default maximum count of samples.
+    ///
+    /// @param max_samples default maximum count of samples to keep.
+    /// (0 means to disable count limit and enable age limit)
+    static void setMaxSampleCountDefault(uint32_t max_samples);
+
+    /// @brief Get default maximum age of samples.
+    ///
+    /// @return default maximum age of samples.
+    static const StatsDuration& getMaxSampleAgeDefault();
+
+    /// @brief Get default maximum count of samples.
+    ///
+    /// @return max_samples default maximum count of samples to keep.
+    /// (0 means that count limit was disabled)
+    static uint32_t getMaxSampleCountDefault();
+
+    /// @
+
     /// @brief Records absolute integer observation
     ///
     /// @param value integer value observed
@@ -354,9 +378,13 @@ private:
     /// The bool value informs which limit
     /// is available
     /// True means active limit, false means inactive limit
+    std::pair<bool, uint32_t> max_sample_count_;
+
+    /// @brief Default maximum number of samples
+    ///
     /// By default the MaxSampleCount is set to 20
     /// and MaxSampleAge is disabled
-    std::pair<bool, uint32_t> max_sample_count_ = std::make_pair(true, 20);
+    static std::pair<bool, uint32_t> default_max_sample_count_;
 
     /// @brief Maximum timespan of samples
     /// The limit is represented as a pair
@@ -365,10 +393,13 @@ private:
     /// The bool value informs which limit
     /// is available
     /// True means active limit, false means inactive limit
+    std::pair<bool, StatsDuration> max_sample_age_;
+
+    /// @brief Default maximum timespan of samples
+    ///
     /// By default the MaxSampleCount is set to 20
     /// and MaxSampleAge is disabled
-    std::pair<bool, StatsDuration> max_sample_age_ = std::make_pair(false,
-            boost::posix_time::time_duration(0, 0, 0, 0));
+    static std::pair<bool, StatsDuration> default_max_sample_age_;
 
     /// @defgroup samples_storage Storage for supported observations
     ///
index 1133afd64c1cfc3d3eb11d9b641a9a8c7b5aace3..f4ce0e0edca6fb5c99ce303f7422732db162f5c5 100644 (file)
@@ -236,6 +236,66 @@ StatsMgr::setMaxSampleCountAllInternal(uint32_t max_samples) {
     global_->setMaxSampleCountAll(max_samples);
 }
 
+void
+StatsMgr::setMaxSampleAgeDefault(const StatsDuration& duration) {
+    if (MultiThreadingMgr::instance().getMode()) {
+        lock_guard<mutex> lock(*mutex_);
+        setMaxSampleAgeDefaultInternal(duration);
+    } else {
+        setMaxSampleAgeDefaultInternal(duration);
+    }
+}
+
+void
+StatsMgr::setMaxSampleAgeDefaultInternal(const StatsDuration& duration) {
+    Observation::setMaxSampleAgeDefault(duration);
+}
+
+void
+StatsMgr::setMaxSampleCountDefault(uint32_t max_samples) {
+    if (MultiThreadingMgr::instance().getMode()) {
+        lock_guard<mutex> lock(*mutex_);
+        setMaxSampleCountDefaultInternal(max_samples);
+    } else {
+        setMaxSampleCountDefaultInternal(max_samples);
+    }
+}
+
+void
+StatsMgr::setMaxSampleCountDefaultInternal(uint32_t max_samples) {
+    Observation::setMaxSampleCountDefault(max_samples);
+}
+
+const StatsDuration&
+StatsMgr::getMaxSampleAgeDefault() const {
+    if (MultiThreadingMgr::instance().getMode()) {
+        lock_guard<mutex> lock(*mutex_);
+        return (getMaxSampleAgeDefaultInternal());
+    } else {
+        return (getMaxSampleAgeDefaultInternal());
+    }
+}
+
+const StatsDuration&
+StatsMgr::getMaxSampleAgeDefaultInternal() const {
+    return (Observation::getMaxSampleAgeDefault());
+}
+
+uint32_t
+StatsMgr::getMaxSampleCountDefault() const {
+    if (MultiThreadingMgr::instance().getMode()) {
+        lock_guard<mutex> lock(*mutex_);
+        return (getMaxSampleCountDefaultInternal());
+    } else {
+        return (getMaxSampleCountDefaultInternal());
+    }
+}
+
+uint32_t
+StatsMgr::getMaxSampleCountDefaultInternal() const {
+    return (Observation::getMaxSampleCountDefault());
+}
+
 bool
 StatsMgr::reset(const string& name) {
     if (MultiThreadingMgr::instance().getMode()) {
index 6ee12ae806fa9654247bfd5a034095060067ae18..e55ad18e4f60f425fa57514a3747e5fdbc122a20 100644 (file)
@@ -170,6 +170,28 @@ public:
     /// @param max_samples how many samples of a given statistic should be kept
     void setMaxSampleCountAll(uint32_t max_samples);
 
+    /// @brief Set default duration limit.
+    ///
+    /// @param duration determines default maximum age of samples
+    void setMaxSampleAgeDefault(const StatsDuration& duration);
+
+    /// @brief Set default count limit.
+    ///
+    /// @param max_samples default maximum number of samples to keep
+    /// (0 means to disable count limit and enable age limit)
+    void setMaxSampleCountDefault(uint32_t max_samples);
+
+    /// @brief Get default duration limit.
+    ///
+    /// @return default maximum age of samples.
+    const StatsDuration& getMaxSampleAgeDefault() const;
+
+    /// @brief Get default count limit.
+    ///
+    /// @return default maximum number of samples to keep.
+    /// (0 means that count limit was disabled)
+    uint32_t getMaxSampleCountDefault() const;
+
     /// @}
 
     /// @defgroup consumer_methods Methods are used by data consumers.
@@ -589,6 +611,40 @@ private:
 
     /// @private
 
+    /// @brief Set default duration limit.
+    ///
+    /// Should be called in a thread safe context.
+    ///
+    /// @param duration determines default maximum age of samples
+    void setMaxSampleAgeDefaultInternal(const StatsDuration& duration);
+
+    /// @brief Set default count limit.
+    ///
+    /// Should be called in a thread safe context.
+    ///
+    /// @param max_samples default maximum number of samples to keep
+    /// (0 means to disable count limit and enable age limit)
+    void setMaxSampleCountDefaultInternal(uint32_t max_samples);
+
+    /// @private
+
+    /// @brief Get default duration limit.
+    ///
+    /// Should be called in a thread safe context.
+    ///
+    /// @return default maximum age of samples.
+    const StatsDuration& getMaxSampleAgeDefaultInternal() const;
+
+    /// @brief Get default count limit.
+    ///
+    /// Should be called in a thread safe context.
+    ///
+    /// @return default maximum number of samples to keep.
+    /// (0 means that count limit was disabled)
+    uint32_t getMaxSampleCountDefaultInternal() const;
+
+    /// @private
+
     /// @brief Resets specified statistic.
     ///
     /// Should be called in a thread safe context.