mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-15 10:03:28 +00:00
Add desync tracking metrics (#2707)
## Description: - Added observable gauge to track total number of client desyncs detected across game servers - Tracks desyncs at the individual client level (counts each out-of-sync client) - Exposes metric as `openfront.desyncs.gauge` for monitoring ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [ ] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user