Skip to content

Commit

Permalink
server: add ott_balancer_connections metric
Browse files Browse the repository at this point in the history
  • Loading branch information
dyc3 committed Apr 29, 2024
1 parent aa795a2 commit c219a92
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/balancer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
},

Check warning on line 445 in server/balancer.ts

View check run for this annotation

Codecov / codecov/patch

server/balancer.ts#L444-L445

Added lines #L444 - L445 were not covered by tests
});

0 comments on commit c219a92

Please sign in to comment.