Add statistics for how far behind the logger falls
This patch adds a new couple of fields to the logger status message to
show how far behind we are in logging.
I added a new unit test to validate that the fields are set.
Change-Id: I41675096056992bcafa3db24d094c4f78379be86
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/events/logging/log_writer.h b/aos/events/logging/log_writer.h
index 265513f..ec02b7d 100644
--- a/aos/events/logging/log_writer.h
+++ b/aos/events/logging/log_writer.h
@@ -77,6 +77,8 @@
void set_logging_delay(std::chrono::nanoseconds logging_delay) {
logging_delay_ = logging_delay;
}
+ // Returns the current logging delay.
+ std::chrono::nanoseconds logging_delay() const { return logging_delay_; }
// Sets the period between polling the data. Defaults to 100ms.
//
@@ -137,6 +139,13 @@
// The total number of bytes copied.
int64_t total_copy_bytes() const { return total_copy_bytes_; }
+ // The maximum time between when a message was sent and when it was logged.
+ // This is 0 if no message has been logged.
+ std::chrono::nanoseconds max_log_delay() const { return max_log_delay_; }
+ // The channel for longest logging delay, or -1 if no messages have been
+ // logged.
+ int max_log_delay_channel() const { return max_log_delay_channel_; }
+
void ResetStatisics();
// Rotates the log file(s), triggering new part files to be written for each
@@ -328,6 +337,9 @@
int total_message_fetch_count_ = 0;
int64_t total_message_fetch_bytes_ = 0;
+ std::chrono::nanoseconds max_log_delay_ = std::chrono::nanoseconds::zero();
+ int max_log_delay_channel_ = -1;
+
std::chrono::nanoseconds total_nop_fetch_time_ =
std::chrono::nanoseconds::zero();
int total_nop_fetch_count_ = 0;