Make protocol message counters more granular:

A running instance of the server tracks the number of protocol messages
and the number of bytes it sends and receives.

This commit makes the counters more granular, allowing server operators
to better track and understand bandwidth usage.
This commit is contained in:
Nik Bougalis
2019-06-21 12:10:06 -07:00
committed by Manoj doshi
parent 2c4b3d515d
commit ba2714fa22
5 changed files with 260 additions and 161 deletions

View File

@@ -593,26 +593,18 @@ void
OverlayImpl::onWrite (beast::PropertyStream::Map& stream)
{
beast::PropertyStream::Set set ("traffic", stream);
auto stats = m_traffic.getCounts();
for (auto& i : stats)
auto const stats = m_traffic.getCounts();
for (auto const& i : stats)
{
if (! i.second.messagesIn && ! i.second.messagesOut)
continue;
beast::PropertyStream::Map item (set);
item["category"] = i.first;
item["bytes_in"] =
beast::lexicalCast<std::string>
(i.second.bytesIn.load());
item["messages_in"] =
beast::lexicalCast<std::string>
(i.second.messagesIn.load());
item["bytes_out"] =
beast::lexicalCast<std::string>
(i.second.bytesOut.load());
item["messages_out"] =
beast::lexicalCast<std::string>
(i.second.messagesOut.load());
if (i)
{
beast::PropertyStream::Map item(set);
item["category"] = i.name;
item["bytes_in"] = std::to_string(i.bytesIn.load());
item["messages_in"] = std::to_string(i.messagesIn.load());
item["bytes_out"] = std::to_string(i.bytesOut.load());
item["messages_out"] = std::to_string(i.messagesOut.load());
}
}
}