From: Franciszek Gorski Date: Thu, 6 Jun 2019 17:28:30 +0000 (+0200) Subject: Support for storing more than one samples X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=341ee8775a834b0cf98adc449a94982d1a44a014;p=thirdparty%2Fkea.git Support for storing more than one samples --- diff --git a/src/lib/stats/observation.cc b/src/lib/stats/observation.cc index c82c1db47b..3e7417386a 100644 --- a/src/lib/stats/observation.cc +++ b/src/lib/stats/observation.cc @@ -188,7 +188,7 @@ void Observation::setValueInternal(SampleType value, StorageType& storage, storage.front().second - storage.back().second; // removing samples until the range_of_storage // stops exceeding the duration limit - while (range_of_storage > max_sample_age_.second) { + while (range_of_storage >= max_sample_age.second) { storage.pop_back(); range_of_storage = storage.front().second - storage.back().second; @@ -317,8 +317,7 @@ std::string Observation::typeToText(Type type) { tmp << "integer"; break; case STAT_FLOAT: - tmp << "float"; - break; + tmp << "float"; break; case STAT_DURATION: tmp << "duration"; break; @@ -335,7 +334,6 @@ std::string Observation::typeToText(Type type) { isc::data::ConstElementPtr Observation::getJSON() const { - ElementPtr entry = isc::data::Element::createList(); // multiple observations ElementPtr value; ElementPtr timestamp; diff --git a/src/lib/stats/tests/observation_unittest.cc b/src/lib/stats/tests/observation_unittest.cc index 1681dcdc34..82f362e906 100644 --- a/src/lib/stats/tests/observation_unittest.cc +++ b/src/lib/stats/tests/observation_unittest.cc @@ -497,6 +497,10 @@ TEST_F(ObservationTest, durationToJSON) { std::string first_sample = ", \"01:02:03.000004\", \"" + isc::util::ptimeToText(c.getDuration().second) + "\" ] ]"; + // String which contains first added sample + std::string first_sample = ", \"01:02:03.000004\", \"" + + isc::util::ptimeToText(c.getDuration().second) + "\" ] ]"; + // 1 hour 2 minutes 3 seconds and 4 milliseconds c.setValue(time_duration(1, 2, 3, 4));