Initial metrics update

This commit is contained in:
yasmin-aumeeruddy 2023-07-25 17:09:18 +01:00
parent 07f6d87ac2
commit ee76d172a9
No known key found for this signature in database
GPG Key ID: DD9F83ABBD83D824
4 changed files with 29 additions and 20 deletions

View File

@ -1,6 +1,9 @@
FROM icr.io/appcafe/open-liberty:kernel-slim-java11-openj9-ubi
ADD --chown=1001:0 build/libs/frontend.war /config/apps
COPY --chown=1001:0 src/main/liberty/config /config/
# Install necessary features
RUN features.sh
RUN printf 'httpPort=12000\n\
httpsPort=12005\n\
application.name=frontend.war' > /config/bootstrap.properties

View File

@ -1,5 +1,6 @@
dependencies {
implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.5'
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.5'
}
ext {

View File

@ -35,7 +35,7 @@ import jakarta.websocket.Session;
import org.eclipse.microprofile.metrics.Timer.Context;
import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.libertybikes.game.core.Player.STATUS;
//import org.libertybikes.game.metric.GameMetrics;
import org.libertybikes.game.metric.GameMetrics;
import org.libertybikes.restclient.PlayerService;
import io.jsonwebtoken.Claims;
@ -199,6 +199,7 @@ public class GameRound implements Runnable {
clients.put(s, c);
log("Player " + playerId + " has joined.");
GameMetrics.incPlayerCount();
/* Increment player counter metrics
GameMetrics.counterInc(GameMetrics.currentPlayersCounter);
GameMetrics.counterInc(GameMetrics.totalPlayersCounter);

View File

@ -5,69 +5,73 @@ package org.libertybikes.game.metric;
import jakarta.enterprise.inject.spi.CDI;
import org.eclipse.microprofile.metrics.MetricRegistry;
import org.eclipse.microprofile.metrics.MetricUnits;
import org.eclipse.microprofile.metrics.Timer.Context;
import org.eclipse.microprofile.metrics.annotation.Counted;
import org.eclipse.microprofile.metrics.Metadata;
import org.eclipse.microprofile.metrics.MetadataBuilder;
import org.eclipse.microprofile.metrics.MetricRegistry;
import org.eclipse.microprofile.metrics.annotation.Gauge;
public class GameMetrics {
// MpMetric Metadatas
/* public static final Metadata totalRoundsCounter = new MetadataBuilder()
private static int totalPlayers = 0;
@Gauge(unit = MetricUnits.NONE,
name = "playerNumberGauge",
absolute = true,
description = "Number of players in the game")
public static int getPlayerCount() {
return totalPlayers;
}
public static void incPlayerCount(){
totalPlayers = totalPlayers + 1;
}
public static void decPlayerCount(){
totalPlayers = totalPlayers -1 ;
}
/*public static final Metadata totalRoundsCounter = new MetadataBuilder()
.withName("total_num_of_rounds")
.withDisplayName("Total Number of Rounds")
.withDescription("Number of rounds that have been created")
.withType(MetricType.COUNTER)
.build();
public static final Metadata currentPlayersCounter = new MetadataBuilder()
.withName("current_num_of_players")
.withDisplayName("Current Number of Players")
.withDescription("Number of players that are currently playing in a round")
.withType(MetricType.CONCURRENT_GAUGE)
.build();
public static final Metadata totalPlayersCounter = new MetadataBuilder()
.withName("total_num_of_players")
.withDisplayName("Total Number of Players That Have Played")
.withDescription("Number of players that have played in a round, requeuing and replaying increases the count")
.withType(MetricType.COUNTER)
.build();
public static final Metadata totalMobilePlayersCounter = new MetadataBuilder()
.withName("total_num_of_mobile_players")
.withDisplayName("Total Number of Mobile Players That Have Played")
.withDescription("Number of mobile players that have played in a round, requeuing and replaying increases the count")
.withType(MetricType.COUNTER)
.build();
public static final Metadata gameRoundTimerMetadata = new MetadataBuilder()
.withName("game_round_timer")
.withDisplayName("Game Round Timer")
.withDescription("The Time Game Rounds Last")
.withType(MetricType.TIMER)
.withUnit(MetricUnits.SECONDS)
.build();
public static final Metadata currentPartiesCounterMetadata = new MetadataBuilder()
.withName("current_number_of_parties")
.withDisplayName("Current Number of Parties")
.withDescription("Number of parties currently running")
.withType(MetricType.CONCURRENT_GAUGE)
.build();
public static final Metadata currentQueuedPlayersCounter = new MetadataBuilder()
.withName("current_num_of_players_in_queue")
.withDisplayName("Current Number of Players Waiting In A Queue")
.withDescription("Number of players that are currently waiting in a queue")
.withType(MetricType.CONCURRENT_GAUGE)
.build();
public static final Metadata openWebsocketTimerMetadata = new MetadataBuilder()
.withName("open_game_websocket_timer")
.withDisplayName("Open Game Round Websocket Timer")
.withDescription("The Time Game Round Websockets Are Open")
.withType(MetricType.TIMER)
.withUnit(MetricUnits.SECONDS)
.build();