fix: Clean up formatting and ensure consistent return structure in metrics endpoints

This commit is contained in:
Nawaz Dhandala
2025-08-01 16:13:05 +01:00
parent c4c6793b29
commit 546d41da81
2 changed files with 6 additions and 7 deletions

View File

@@ -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);

View File

@@ -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);