From bba383bf1bb94d8ef8a1deb50ed5a300569f41ba Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 24 Jul 2017 16:26:44 +0200 Subject: [PATCH] hydra-queue-runner: Keep some notification statistics --- src/hydra-queue-runner/hydra-queue-runner.cc | 17 +++++++++++++++++ src/hydra-queue-runner/state.hh | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index 1a67e1f4..c38c8021 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -485,8 +485,12 @@ void State::notificationSender() notificationSenderQueue_->pop(); } + MaintainCount mc(nrNotificationsInProgress); + printMsg(lvlChatty, format("sending notification about build %1%") % item.id); + auto now1 = std::chrono::steady_clock::now(); + Pid pid = startProcess([&]() { Strings argv; switch (item.type) { @@ -513,7 +517,13 @@ void State::notificationSender() if (!statusOk(res)) throw Error("notification about build %d failed: %s", item.id, statusToString(res)); + auto now2 = std::chrono::steady_clock::now(); + + nrNotificationTimeMs += std::chrono::duration_cast(now2 - now1).count(); + nrNotificationsDone++; + } catch (std::exception & e) { + nrNotificationsFailed++; printMsg(lvlError, format("notification sender: %1%") % e.what()); sleep(5); } @@ -589,6 +599,13 @@ void State::dumpStatus(Connection & conn, bool log) root.attr("nrDbConnections", dbPool.count()); root.attr("nrActiveDbUpdates", nrActiveDbUpdates); root.attr("memoryTokensInUse", memoryTokens.currentUse()); + root.attr("nrNotificationsDone", nrNotificationsDone); + root.attr("nrNotificationsFailed", nrNotificationsFailed); + root.attr("nrNotificationsInProgress", nrNotificationsInProgress); + root.attr("nrNotificationsPending", notificationSenderQueue.lock()->size()); + root.attr("nrNotificationTimeMs", nrNotificationTimeMs); + uint64_t nrNotificationsTotal = nrNotificationsDone + nrNotificationsFailed; + root.attr("nrNotificationTimeAvgMs", nrNotificationsTotal == 0 ? 0.0 : (float) nrNotificationTimeMs / nrNotificationsTotal); { auto nested = root.object("machines"); diff --git a/src/hydra-queue-runner/state.hh b/src/hydra-queue-runner/state.hh index 38489f27..b9d98cd3 100644 --- a/src/hydra-queue-runner/state.hh +++ b/src/hydra-queue-runner/state.hh @@ -334,6 +334,10 @@ private: counter bytesSent{0}; counter bytesReceived{0}; counter nrActiveDbUpdates{0}; + counter nrNotificationsDone{0}; + counter nrNotificationsFailed{0}; + counter nrNotificationsInProgress{0}; + counter nrNotificationTimeMs{0}; /* Notification sender work queue. FIXME: if hydra-queue-runner is killed before it has finished sending notifications about a