Add per-channel statistics to message bridge ServerStatistics
When trying to debug issues with message bridge, we wanted to be able to
tell which channels were having issues. This will help with it (although
like the timing reports, it will help to have a utility to transform
from channel indices to channel names).
Change-Id: Ief2a11c7b45e32cc8bc4ab6861e05b7f57aaeb9c
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/events/simulated_event_loop_test.cc b/aos/events/simulated_event_loop_test.cc
index 14e0a08..0afa22e 100644
--- a/aos/events/simulated_event_loop_test.cc
+++ b/aos/events/simulated_event_loop_test.cc
@@ -619,6 +619,17 @@
EXPECT_TRUE(connection->has_monotonic_offset());
EXPECT_EQ(connection->monotonic_offset(), 0);
+
+ EXPECT_TRUE(connection->has_channels());
+ int accumulated_sent_count = 0;
+ int accumulated_dropped_count = 0;
+ for (const message_bridge::ServerChannelStatistics *channel :
+ *connection->channels()) {
+ accumulated_sent_count += channel->sent_packets();
+ accumulated_dropped_count += channel->dropped_packets();
+ }
+ EXPECT_EQ(connection->sent_packets(), accumulated_sent_count);
+ EXPECT_EQ(connection->dropped_packets(), accumulated_dropped_count);
}
++pi1_server_statistics_count;
});
@@ -639,6 +650,18 @@
EXPECT_EQ(connection->monotonic_offset(), 0);
EXPECT_EQ(connection->connection_count(), 1u);
EXPECT_EQ(connection->connected_since_time(), 0);
+
+ EXPECT_TRUE(connection->has_channels());
+ int accumulated_sent_count = 0;
+ int accumulated_dropped_count = 0;
+ for (const message_bridge::ServerChannelStatistics *channel :
+ *connection->channels()) {
+ accumulated_sent_count += channel->sent_packets();
+ accumulated_dropped_count += channel->dropped_packets();
+ }
+ EXPECT_EQ(connection->sent_packets(), accumulated_sent_count);
+ EXPECT_EQ(connection->dropped_packets(), accumulated_dropped_count);
+
++pi2_server_statistics_count;
});
@@ -658,6 +681,18 @@
EXPECT_EQ(connection->monotonic_offset(), 0);
EXPECT_EQ(connection->connection_count(), 1u);
EXPECT_EQ(connection->connected_since_time(), 0);
+
+ EXPECT_TRUE(connection->has_channels());
+ int accumulated_sent_count = 0;
+ int accumulated_dropped_count = 0;
+ for (const message_bridge::ServerChannelStatistics *channel :
+ *connection->channels()) {
+ accumulated_sent_count += channel->sent_packets();
+ accumulated_dropped_count += channel->dropped_packets();
+ }
+ EXPECT_EQ(connection->sent_packets(), accumulated_sent_count);
+ EXPECT_EQ(connection->dropped_packets(), accumulated_dropped_count);
+
++pi3_server_statistics_count;
});