Fixed issue with wrong timestamp
Telemetry service used steady_clock for generating timestamps, but it
produced incorrect time. This change makes telemetry service use
steady_clock for intervals and system_clock for timestamps.
Changed readings timestamp to display current timestamp instead of a
time when reading was received.
Tested:
- correct timestamp is visible on dbus
- other telemetry service features are still working
Change-Id: Ic49f45640532cfffaeff5e0bd5591e6d99e5def5
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/src/report.cpp b/src/report.cpp
index 54189e3..170f50d 100644
--- a/src/report.cpp
+++ b/src/report.cpp
@@ -21,7 +21,7 @@
interfaces::ReportManager& reportManager,
interfaces::JsonStorage& reportStorageIn,
std::vector<std::shared_ptr<interfaces::Metric>> metricsIn,
- const bool enabledIn) :
+ const bool enabledIn, std::unique_ptr<interfaces::Clock> clock) :
id(reportId),
name(reportName), reportingType(reportingTypeIn), interval(intervalIn),
reportActions(std::move(reportActionsIn)),
@@ -30,7 +30,7 @@
reportUpdates(reportUpdatesIn),
readingsBuffer(deduceBufferSize(reportUpdates, reportingType)),
objServer(objServer), metrics(std::move(metricsIn)), timer(ioc),
- reportStorage(reportStorageIn), enabled(enabledIn)
+ reportStorage(reportStorageIn), enabled(enabledIn), clock(std::move(clock))
{
readingParameters =
toReadingParameters(utils::transform(metrics, [](const auto& metric) {
@@ -318,7 +318,8 @@
}
readings = {
- Clock().timestamp(),
+ std::chrono::duration_cast<Milliseconds>(clock->systemTimestamp())
+ .count(),
std::vector<ReadingData>(readingsBuffer.begin(), readingsBuffer.end())};
reportIface->signal_property("Readings");