Add metrics for pending request

Track the number of requests currently awaiting a response from a
request handler both from interally issued requests and requests
forwarded from other parties.
This commit is contained in:
Hornwitser committed 2024-01-22 20:48:01 +01:00
1 parent 51fe6c9519
commit d7edae99c5
4 files changed
+53 -6

No files matched your search

+18
View File
@@ -37,6 +37,24 @@ import { version } from "./package.json";
// globals
let controller: Controller;
void new lib.Gauge(
"clusterio_controller_pending_requests",
"Count of pending link requests currently waiting in memory on the controller.",
{
callback: (gauge) => {
let count = 0;
if (controller) {
for (const host of controller.wsServer.hostConnections.values()) {
count += host.pendingRequestCount;
}
for (const control of controller.wsServer.controlConnections.values()) {
count += control.pendingRequestCount;
}
}
gauge.set(count);
},
}
);
void new lib.Gauge(
"clusterio_controller_host_mapping",