mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix: Add checkedAt property to IncomingMonitorRequest and update its usage in request processing
This commit is contained in:
@@ -91,7 +91,8 @@ export default class IncomingRequestCriteria {
|
||||
|
||||
const differenceInMinutes: number = OneUptimeDate.getDifferenceInMinutes(
|
||||
lastCheckTime,
|
||||
OneUptimeDate.getCurrentDate(),
|
||||
(input.dataToProcess as IncomingMonitorRequest)?.checkedAt ||
|
||||
OneUptimeDate.getCurrentDate(),
|
||||
);
|
||||
|
||||
logger.debug("Difference in minutes: " + differenceInMinutes);
|
||||
|
||||
@@ -11,4 +11,5 @@ export default interface IncomingMonitorRequest {
|
||||
requestMethod?: HTTPMethod | undefined;
|
||||
incomingRequestReceivedAt: Date;
|
||||
onlyCheckForIncomingRequestReceivedAt?: boolean | undefined;
|
||||
checkedAt: Date;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import Express, {
|
||||
import MonitorResourceUtil from "Common/Server/Utils/Monitor/MonitorResource";
|
||||
import Response from "Common/Server/Utils/Response";
|
||||
import Monitor from "Common/Models/DatabaseModels/Monitor";
|
||||
import logger from "Common/Server/Utils/Logger";
|
||||
|
||||
const router: ExpressRouter = Express.getRouter();
|
||||
|
||||
@@ -72,18 +73,26 @@ const processIncomingRequest: RequestHandler = async (
|
||||
throw new BadDataException("Project not found");
|
||||
}
|
||||
|
||||
const now: Date = OneUptimeDate.getCurrentDate();
|
||||
|
||||
const incomingRequest: IncomingMonitorRequest = {
|
||||
projectId: monitor.projectId,
|
||||
monitorId: new ObjectID(monitor._id.toString()),
|
||||
requestHeaders: requestHeaders,
|
||||
requestBody: requestBody,
|
||||
incomingRequestReceivedAt: OneUptimeDate.getCurrentDate(),
|
||||
incomingRequestReceivedAt: now,
|
||||
onlyCheckForIncomingRequestReceivedAt: false,
|
||||
requestMethod: httpMethod,
|
||||
checkedAt: now,
|
||||
};
|
||||
|
||||
// process probe response here.
|
||||
await MonitorResourceUtil.monitorResource(incomingRequest);
|
||||
MonitorResourceUtil.monitorResource(incomingRequest).catch((err: Error) => {
|
||||
// do nothing.
|
||||
// we don't want to throw error here.
|
||||
// we just want to log the error.
|
||||
logger.error(err);
|
||||
});
|
||||
|
||||
return Response.sendEmptySuccessResponse(req, res);
|
||||
} catch (err) {
|
||||
|
||||
@@ -153,6 +153,7 @@ const checkHeartBeat: (monitor: Monitor) => Promise<void> = async (
|
||||
onlyCheckForIncomingRequestReceivedAt: true,
|
||||
monitorId: monitor.id!,
|
||||
projectId: monitor.projectId!,
|
||||
checkedAt: OneUptimeDate.getCurrentDate(),
|
||||
};
|
||||
|
||||
logger.debug(
|
||||
|
||||
Reference in New Issue
Block a user