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_network_bridge.cc b/aos/events/simulated_network_bridge.cc
index b363142..35cc3a6 100644
--- a/aos/events/simulated_network_bridge.cc
+++ b/aos/events/simulated_network_bridge.cc
@@ -54,6 +54,8 @@
if (server_status) {
server_connection_ =
server_status_->FindServerConnection(send_node_factory_->node());
+ server_index_ = configuration::GetNodeIndex(
+ send_node_factory_->configuration(), send_node_factory_->node());
}
if (delivery_time_is_logged_ && timestamp_loggers != nullptr &&
!forwarding_disabled_) {
@@ -153,13 +155,11 @@
<< " at " << fetch_node_factory_->monotonic_now();
if (timer_) {
- server_connection_->mutate_sent_packets(
- server_connection_->sent_packets() + 1);
+ server_status_->AddSentPacket(server_index_, channel_);
timer_->Schedule(monotonic_delivered_time);
timer_scheduled_ = true;
} else {
- server_connection_->mutate_dropped_packets(
- server_connection_->dropped_packets() + 1);
+ server_status_->AddDroppedPacket(server_index_, channel_);
sent_ = true;
}
}
@@ -192,13 +192,11 @@
<< " at " << fetch_node_factory_->monotonic_now();
if (timer_) {
- server_connection_->mutate_sent_packets(
- server_connection_->sent_packets() + 1);
+ server_status_->AddSentPacket(server_index_, channel_);
timer_->Schedule(monotonic_delivered_time);
timer_scheduled_ = true;
} else {
- server_connection_->mutate_dropped_packets(
- server_connection_->dropped_packets() + 1);
+ server_status_->AddDroppedPacket(server_index_, channel_);
sent_ = true;
Schedule();
}
@@ -218,8 +216,7 @@
if (server_connection_->state() != State::CONNECTED) {
sent_ = true;
- server_connection_->mutate_dropped_packets(
- server_connection_->dropped_packets() + 1);
+ server_status_->AddDroppedPacket(server_index_, channel_);
continue;
}
@@ -241,8 +238,7 @@
<< fetcher_->context().monotonic_event_time << " now is "
<< fetch_node_factory_->monotonic_now();
sent_ = true;
- server_connection_->mutate_dropped_packets(
- server_connection_->dropped_packets() + 1);
+ server_status_->AddDroppedPacket(server_index_, channel_);
}
}
@@ -400,6 +396,7 @@
bool sent_ = false;
ServerConnection *server_connection_ = nullptr;
+ int server_index_ = -1;
MessageBridgeClientStatus *client_status_ = nullptr;
int client_index_ = -1;
ClientConnection *client_connection_ = nullptr;