From d9ebbfe99e2ff2c3498d9a4992889e55f9ded01a Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Apr 2024 12:37:46 +0100 Subject: [PATCH] update metrics websocket json response --- .../mcutils/backend/websocket/MetricsWebSocketHandler.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/xyz/mcutils/backend/websocket/MetricsWebSocketHandler.java b/src/main/java/xyz/mcutils/backend/websocket/MetricsWebSocketHandler.java index 8802972..4294c0f 100644 --- a/src/main/java/xyz/mcutils/backend/websocket/MetricsWebSocketHandler.java +++ b/src/main/java/xyz/mcutils/backend/websocket/MetricsWebSocketHandler.java @@ -42,13 +42,11 @@ public class MetricsWebSocketHandler extends TextWebSocketHandler { */ private void sendMetrics(WebSocketSession session) { try { - WebsocketMetrics metrics = new WebsocketMetrics(Map.of( + session.sendMessage(new TextMessage(Main.GSON.toJson(Map.of( "totalRequests", metricService.getMetric(TotalRequestsMetric.class).getValue(), "totalServerLookups", metricService.getMetric(TotalServerLookupsMetric.class).getValue(), "totalPlayerLookups", metricService.getMetric(TotalPlayerLookupsMetric.class).getValue() - )); - - session.sendMessage(new TextMessage(Main.GSON.toJson(metrics))); + )))); } catch (Exception e) { log.error("An error occurred while sending metrics to the client", e); }