hydra-queue-runner: Keep some notification statistics

This commit is contained in:
Eelco Dolstra 2017-07-24 16:26:44 +02:00
parent f46a21e16e
commit bba383bf1b
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
2 changed files with 21 additions and 0 deletions

View file

@ -485,8 +485,12 @@ void State::notificationSender()
notificationSenderQueue_->pop(); notificationSenderQueue_->pop();
} }
MaintainCount mc(nrNotificationsInProgress);
printMsg(lvlChatty, format("sending notification about build %1%") % item.id); printMsg(lvlChatty, format("sending notification about build %1%") % item.id);
auto now1 = std::chrono::steady_clock::now();
Pid pid = startProcess([&]() { Pid pid = startProcess([&]() {
Strings argv; Strings argv;
switch (item.type) { switch (item.type) {
@ -513,7 +517,13 @@ void State::notificationSender()
if (!statusOk(res)) if (!statusOk(res))
throw Error("notification about build %d failed: %s", item.id, statusToString(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<std::chrono::milliseconds>(now2 - now1).count();
nrNotificationsDone++;
} catch (std::exception & e) { } catch (std::exception & e) {
nrNotificationsFailed++;
printMsg(lvlError, format("notification sender: %1%") % e.what()); printMsg(lvlError, format("notification sender: %1%") % e.what());
sleep(5); sleep(5);
} }
@ -589,6 +599,13 @@ void State::dumpStatus(Connection & conn, bool log)
root.attr("nrDbConnections", dbPool.count()); root.attr("nrDbConnections", dbPool.count());
root.attr("nrActiveDbUpdates", nrActiveDbUpdates); root.attr("nrActiveDbUpdates", nrActiveDbUpdates);
root.attr("memoryTokensInUse", memoryTokens.currentUse()); 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"); auto nested = root.object("machines");

View file

@ -334,6 +334,10 @@ private:
counter bytesSent{0}; counter bytesSent{0};
counter bytesReceived{0}; counter bytesReceived{0};
counter nrActiveDbUpdates{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 /* Notification sender work queue. FIXME: if hydra-queue-runner is
killed before it has finished sending notifications about a killed before it has finished sending notifications about a