Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
bf08be8
Revert temp fix for failed fetch requests
kev306 Jul 3, 2024
8b10620
Added labelOptions checks. Also on counter config, increment all
kev306 Jul 4, 2024
899f447
Added labelCombination validations on counter config and inc methods
kev306 Jul 4, 2024
58c4d66
Updated custom avatar metric labelOptions
kev306 Jul 4, 2024
296b700
Minor update to error messages
kev306 Jul 4, 2024
8500dcd
Updated gauge to also validate labels
kev306 Jul 4, 2024
47e8623
Removed labelNames from counterConfig in favor of labelOptions
kev306 Jul 5, 2024
a48f378
Added checks for invalid configurations
kev306 Jul 5, 2024
2740fa2
Minor update
kev306 Jul 5, 2024
71a0562
Updating labelOptions to be a Set
kev306 Jul 5, 2024
16e902d
Updated generateMetricCombinations
kev306 Jul 5, 2024
aaff0dc
Updated valid label combination check for counter inc method
kev306 Jul 5, 2024
03ac410
Removed labelCombinations attribute from PromMetricCounter class
kev306 Jul 5, 2024
2c1d2e6
Removed unused function
kev306 Jul 5, 2024
e5fe498
Minor updaet
kev306 Jul 5, 2024
cf1ab19
Added test cases for generateLabelCombinations. Updated function for
kev306 Jul 6, 2024
e289292
Added check for empty labelOptions
kev306 Jul 6, 2024
bd4a15c
Updated constructor for promClientCounter
kev306 Jul 6, 2024
1860660
Added test cases for promMetricCounter partially
kev306 Jul 6, 2024
f75553a
Fixed inc mock
kev306 Jul 6, 2024
85a71f5
Added test functions for increment method for counter
kev306 Jul 6, 2024
d0dae22
Changed from recursive back to map
kev306 Jul 6, 2024
81bd6c0
Minor update
kev306 Jul 6, 2024
f0d96b1
Minor update
kev306 Jul 6, 2024
fea929b
Updated gauge
kev306 Jul 6, 2024
c401d16
Added test cases for gauge
kev306 Jul 6, 2024
c35434c
Minor updates
kev306 Jul 6, 2024
c68e0fa
Added metric to distinguish between custom and matchmade games
kev306 Jul 7, 2024
91b6ae4
Removed unused function
kev306 Jul 7, 2024
68810e8
Added private game label
kev306 Jul 7, 2024
c0a1d94
Renamed type to game_type for clarity
kev306 Jul 7, 2024
3fa626f
Removed unnecessary console log
kev306 Jul 7, 2024
18af394
Merge branch 'master' of github.com:vck3000/ProAvalon into update/gam…
kev306 Jul 22, 2024
9cfa3cd
Minor update
kev306 Jul 22, 2024
e42df33
Added a roomCreationMapping function to map between room type and metric
kev306 Jul 22, 2024
11159a3
Reverted private room type changes
kev306 Aug 15, 2024
7fce7d2
Updated gamesPlayedMetric room type for private and matchmade games
kev306 Aug 15, 2024
bb7fe3c
Fixed metrics
kev306 Aug 15, 2024
ac0d3eb
Updated enum name
kev306 Aug 15, 2024
e1b39ba
Minor update
kev306 Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/gameplay/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ import { millisToStr } from '../util/time';
import shuffleArray from '../util/shuffleArray';
import { Anonymizer } from './anonymizer';
import { sendReplyToCommand } from '../sockets/sockets';
import { gamesPlayedMetric } from '../metrics/gameMetrics';
import {
gamesPlayedMetric,
getGameMetricRoomType,
} from '../metrics/gameMetrics';

export const WAITING = 'Waiting';
export const MIN_PLAYERS = 5;
Expand Down Expand Up @@ -527,7 +530,6 @@ class Game extends Room {
this.pickNum = 1;
this.missionHistory = [];

console.log(this.ranked);
let str = '';
if (this.ranked === true) {
str = 'This game is ranked.';
Expand Down Expand Up @@ -1255,7 +1257,10 @@ class Game extends Room {
}

// From this point on, no more game moves can be made. Game is finished.
gamesPlayedMetric.inc(1, { status: 'finished' });
gamesPlayedMetric.inc(1, {
status: 'finished',
room_type: getGameMetricRoomType(this),
});

// Clean up from here.
for (let i = 0; i < this.allSockets.length; i++) {
Expand Down Expand Up @@ -2077,7 +2082,10 @@ class Game extends Room {
}

if (this.voidGameTracker.playerVoted(socket.request.user.username)) {
gamesPlayedMetric.inc(1, { status: 'voided' });
gamesPlayedMetric.inc(1, {
status: 'voided',
room_type: getGameMetricRoomType(this),
});

this.changePhase(Phase.Voided);
this.sendText(`Game has been voided.`, 'server-text');
Expand Down
12 changes: 0 additions & 12 deletions src/gameplay/roomTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,3 @@ export enum RoomCreationType {
QUEUE = 'QUEUE',
CUSTOM_ROOM = 'CUSTOM_ROOM',
}

export function strToRoomCreationType(typeString: string): RoomCreationType {
switch (typeString) {
case RoomCreationType.QUEUE:
return RoomCreationType.QUEUE;
case RoomCreationType.CUSTOM_ROOM:
return RoomCreationType.CUSTOM_ROOM;
default:
console.warn(`Invalid roomCreationType string. Got ${typeString}`);
return RoomCreationType.CUSTOM_ROOM;
}
}
21 changes: 21 additions & 0 deletions src/metrics/gameMetrics.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
import { PromMetricCounter } from '../clients/victoriaMetrics/promMetricCounter';
import Game from '../gameplay/game';
import { RoomCreationType } from '../gameplay/roomTypes';

enum GameMetricRoomType {
MATCHMAKING = 'matchmaking',
PUBLIC = 'public',
PRIVATE = 'private',
}

export const gamesPlayedMetric = new PromMetricCounter({
name: 'games_played_total',
help: 'Total number of games played.',
labelOptions: {
status: new Set(['finished', 'voided']),
room_type: new Set(Object.values(GameMetricRoomType)),
},
});

export function getGameMetricRoomType(game: Game): GameMetricRoomType {
if (game.roomCreationType == RoomCreationType.QUEUE) {
return GameMetricRoomType.MATCHMAKING;
} else if (game.joinPassword) {
return GameMetricRoomType.PRIVATE;
} else if (!game.joinPassword) {
return GameMetricRoomType.PUBLIC;
} else {
throw new Error('Undefined game room type.');
}
}
1 change: 0 additions & 1 deletion src/sockets/sockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,6 @@ function newRoom(dataObj) {
roomConfig,
dataObj.muteSpectators,
dataObj.disableVoteHistory,
RoomCreationType.CUSTOM_ROOM,
() => new Date(),
);

Expand Down