Review fixes for 'Created metric class'
- Changed metric to_json to dumpConfiguration returning LabeledTuple
- LabeledTuple can be created and assigned directly to json
- LabeledTuple can be readed from json using json.get<LabeledTuple>
- Added PrintTo for LabeledMetricParams, LabeledSensorParams
- Added helper method expectMake to ReportFactoryMock
- sensorPaths are serialized to tuple<service, path> instead of single
field with service and path separated via ':'
- Changed configuration version from 1 to 2
Change-Id: I7c45fb584687172f88fd549a93329264793b0b8e
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/src/report.cpp b/src/report.cpp
index 4d91787..dc8f37b 100644
--- a/src/report.cpp
+++ b/src/report.cpp
@@ -28,11 +28,6 @@
fileName(std::to_string(std::hash<std::string>{}(name))),
reportStorage(reportStorageIn)
{
- for (auto& metric : this->metrics)
- {
- metric->initialize();
- }
-
deleteIface = objServer->add_unique_interface(
path, deleteIfaceName, [this, &ioc, &reportManager](auto& dbusIface) {
dbusIface.register_method("Delete", [this, &ioc, &reportManager] {
@@ -121,6 +116,11 @@
{
scheduleTimer(interval);
}
+
+ for (auto& metric : this->metrics)
+ {
+ metric->initialize();
+ }
}
void Report::timerProc(boost::system::error_code ec, Report& self)
@@ -179,8 +179,10 @@
data["EmitsReadingsUpdate"] = emitsReadingsUpdate;
data["LogToMetricReportsCollection"] = logToMetricReportsCollection;
data["Interval"] = interval.count();
- data["ReadingParameters"] = utils::transform(
- metrics, [](const auto& metric) { return metric->to_json(); });
+ data["ReadingParameters"] =
+ utils::transform(metrics, [](const auto& metric) {
+ return metric->dumpConfiguration();
+ });
reportStorage.store(fileName, data);
}