Add request queue size rpc stat

Summary:
The queue size stat is updated every time we pop from queue.
This means it won't get updated if we get requests while all threads are
busy processing some long running request. I don't think we care about
the exact queue size in that case, so that is fine.

Reviewers: mferencevic

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1213
This commit is contained in:
Marin Tomic 2018-02-19 17:01:48 +01:00
parent 0c40c67ac2
commit 6236fbbcb4

View File

@ -56,11 +56,14 @@ Server::Server(System &system, const std::string &service_name,
int workers_count)
: system_(system), service_name_(service_name) {
system_.Add(*this);
stats::Gauge &queue_size =
stats::GetGauge(fmt::format("rpc.server.{}.queue_size", service_name));
for (int i = 0; i < workers_count; ++i) {
threads_.push_back(std::thread([this, service_name]() {
threads_.push_back(std::thread([this, service_name, &queue_size]() {
// TODO: Add logging.
while (alive_) {
auto task = queue_.AwaitPop();
queue_size.Set(queue_.size());
if (!task) continue;
auto socket = std::move(std::get<0>(*task));
auto message_id = std::get<1>(*task);