From 6236fbbcb494cbded11493132223aef06ec82f78 Mon Sep 17 00:00:00 2001 From: Marin Tomic Date: Mon, 19 Feb 2018 17:01:48 +0100 Subject: [PATCH] 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 --- src/communication/rpc/server.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/communication/rpc/server.cpp b/src/communication/rpc/server.cpp index daec28e52..d7563db16 100644 --- a/src/communication/rpc/server.cpp +++ b/src/communication/rpc/server.cpp @@ -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);