From c219a921af6f29beef97bbecdcb22d9036267f01 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Mon, 29 Apr 2024 10:53:34 -0400 Subject: [PATCH] server: add `ott_balancer_connections` metric --- server/balancer.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/balancer.ts b/server/balancer.ts index 535f4c3a0..4af730d95 100644 --- a/server/balancer.ts +++ b/server/balancer.ts @@ -12,6 +12,7 @@ import roommanager from "./roommanager"; import type { RoomListItem } from "./api/room"; import _ from "lodash"; import type { MsgB2M, MsgM2B, UnloadReason } from "./generated"; +import { Gauge } from "prom-client"; export type { MsgB2M, MsgM2B }; const log = getLogger("balancer"); @@ -435,3 +436,11 @@ function gossip() { const gossipDebounced = _.debounce(gossip, 1000 * 20, { trailing: true, maxWait: 1000 * 20 }); interface GossipRoom extends RoomListItem {} + +const gaugeBalancerConnections = new Gauge({ + name: "ott_balancer_connections", + help: "Number of balancer connections", + collect() { + this.set(balancerManager.balancerConnections.length); + }, +});