From 546d41da8194bf5207d28682d6767f8102432164 Mon Sep 17 00:00:00 2001 From: Nawaz Dhandala Date: Fri, 1 Aug 2025 16:13:05 +0100 Subject: [PATCH] fix: Clean up formatting and ensure consistent return structure in metrics endpoints --- Probe/API/Metrics.ts | 7 +++---- ProbeIngest/API/Probe.ts | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Probe/API/Metrics.ts b/Probe/API/Metrics.ts index 44dae239a3..3a4651d518 100644 --- a/Probe/API/Metrics.ts +++ b/Probe/API/Metrics.ts @@ -41,24 +41,23 @@ router.get( HTTPMethod.POST, queueSizeUrl, requestBody, - {} + {}, ); if (result instanceof HTTPErrorResponse) { logger.error("Error fetching queue size from ProbeIngest API"); logger.error(result); - throw result; + throw result; } // Extract queueSize from the response - const queueSize = result.data["queueSize"] || 0; + const queueSize: number = result.data["queueSize"] || 0; logger.debug(`Queue size fetched: ${queueSize}`); return Response.sendJsonObjectResponse(req, res, { queueSize: queueSize, }); - } catch (err) { logger.error("Error in metrics queue-size endpoint"); logger.error(err); diff --git a/ProbeIngest/API/Probe.ts b/ProbeIngest/API/Probe.ts index b6a88d3769..efe30a98c4 100644 --- a/ProbeIngest/API/Probe.ts +++ b/ProbeIngest/API/Probe.ts @@ -380,7 +380,7 @@ router.post( try { // This endpoint returns the number of monitors pending for the specific probe // to be used by Keda for autoscaling probe replicas - + // Get the probe ID from the authenticated request const data: JSONObject = req.body; const probeId: ObjectID = new ObjectID(data["probeId"] as string); @@ -413,8 +413,8 @@ router.post( }, }); - return Response.sendJsonObjectResponse(req, res, { - queueSize: pendingCount.toNumber() + return Response.sendJsonObjectResponse(req, res, { + queueSize: pendingCount.toNumber(), }); } catch (err) { return next(err);