Merge branch 'v28'

This commit is contained in:
evanpelle
2026-01-01 14:25:45 -08:00
38 changed files with 140 additions and 365 deletions
+8
View File
@@ -94,6 +94,14 @@ export class GameManager {
return totalClients;
}
desyncCount(): number {
let totalDesyncs = 0;
this.games.forEach((game: GameServer) => {
totalDesyncs += game.desyncCount;
});
return totalDesyncs;
}
tick() {
const active = new Map<GameID, GameServer>();
for (const [id, game] of this.games) {
+4
View File
@@ -71,6 +71,8 @@ export class GameServer {
{ winner: ClientSendWinnerMessage; ips: Set<string> }
> = new Map();
public desyncCount = 0;
constructor(
public readonly id: string,
readonly log_: Logger,
@@ -831,6 +833,8 @@ export class GameServer {
const { mostCommonHash, outOfSyncClients } =
this.findOutOfSyncClients(lastHashTurn);
this.desyncCount += outOfSyncClients.length;
if (outOfSyncClients.length === 0) {
this.turns[lastHashTurn].hash = mostCommonHash;
return;
+9 -3
View File
@@ -59,6 +59,10 @@ export function initWorkerMetrics(gameManager: GameManager): void {
},
);
const desyncsGauge = meter.createObservableGauge("openfront.desyncs.gauge", {
description: "Number of detected desyncs on active games on this worker",
});
const memoryUsageGauge = meter.createObservableGauge(
"openfront.memory_usage.bytes",
{
@@ -66,19 +70,21 @@ export function initWorkerMetrics(gameManager: GameManager): void {
},
);
// Register callback for active games metric
activeGamesGauge.addCallback((result) => {
const count = gameManager.activeGames();
result.observe(count, getPromLabels());
});
// Register callback for connected clients metric
connectedClientsGauge.addCallback((result) => {
const count = gameManager.activeClients();
result.observe(count, getPromLabels());
});
// Register callback for memory usage metric
desyncsGauge.addCallback((result) => {
const count = gameManager.desyncCount();
result.observe(count, getPromLabels());
});
memoryUsageGauge.addCallback((result) => {
const memoryUsage = process.memoryUsage();
result.observe(memoryUsage.heapUsed, getPromLabels());