Merge pull request #413 from thecodingmachine/nbRoomsGauge
FEAT: added a prometheus gauge for the number of active rooms
This commit is contained in:
commit
74ec363449
@ -6,8 +6,13 @@ class GaugeManager {
|
|||||||
private nbClientsPerRoomGauge: Gauge<string>;
|
private nbClientsPerRoomGauge: Gauge<string>;
|
||||||
private nbGroupsPerRoomGauge: Gauge<string>;
|
private nbGroupsPerRoomGauge: Gauge<string>;
|
||||||
private nbGroupsPerRoomCounter: Counter<string>;
|
private nbGroupsPerRoomCounter: Counter<string>;
|
||||||
|
private nbRoomsGauge: Gauge<string>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
this.nbRoomsGauge = new Gauge({
|
||||||
|
name: 'workadventure_nb_rooms',
|
||||||
|
help: 'Number of active rooms'
|
||||||
|
});
|
||||||
this.nbClientsGauge = new Gauge({
|
this.nbClientsGauge = new Gauge({
|
||||||
name: 'workadventure_nb_sockets',
|
name: 'workadventure_nb_sockets',
|
||||||
help: 'Number of connected sockets',
|
help: 'Number of connected sockets',
|
||||||
@ -31,6 +36,13 @@ class GaugeManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
incNbRoomGauge(): void {
|
||||||
|
this.nbRoomsGauge.inc();
|
||||||
|
}
|
||||||
|
decNbRoomGauge(): void {
|
||||||
|
this.nbRoomsGauge.dec();
|
||||||
|
}
|
||||||
|
|
||||||
incNbClientPerRoomGauge(roomId: string): void {
|
incNbClientPerRoomGauge(roomId: string): void {
|
||||||
this.nbClientsGauge.inc();
|
this.nbClientsGauge.inc();
|
||||||
this.nbClientsPerRoomGauge.inc({ room: roomId });
|
this.nbClientsPerRoomGauge.inc({ room: roomId });
|
||||||
|
@ -351,6 +351,7 @@ export class SocketManager {
|
|||||||
world.leave(Client);
|
world.leave(Client);
|
||||||
if (world.isEmpty()) {
|
if (world.isEmpty()) {
|
||||||
this.Worlds.delete(Client.roomId);
|
this.Worlds.delete(Client.roomId);
|
||||||
|
gaugeManager.decNbRoomGauge();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//user leave previous room
|
//user leave previous room
|
||||||
@ -383,6 +384,7 @@ export class SocketManager {
|
|||||||
world.tags = data.tags
|
world.tags = data.tags
|
||||||
world.policyType = Number(data.policy_type)
|
world.policyType = Number(data.policy_type)
|
||||||
}
|
}
|
||||||
|
gaugeManager.incNbRoomGauge();
|
||||||
this.Worlds.set(roomId, world);
|
this.Worlds.set(roomId, world);
|
||||||
}
|
}
|
||||||
return Promise.resolve(world)
|
return Promise.resolve(world)
|
||||||
|
Loading…
Reference in New Issue
Block a user