Merge pull request #3523 from bluewave-labs/fix/initialization-state
fix: monitor init
This commit is contained in:
1 file changed
+10
-4
@@ -257,12 +257,18 @@ export class StatusService implements IStatusService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// With a full window, a single raw check must not change monitor.status; only the sliding-window threshold can trigger a transition.
|
// With a full window, a single raw check must not change UNLESS we are initializing. Otherwise, only the sliding-window threshold can trigger a transition.
|
||||||
let newStatus = monitor.status;
|
let newStatus: MonitorStatus;
|
||||||
|
if (monitor.status === "initializing") {
|
||||||
|
newStatus = status === true ? "up" : "down";
|
||||||
|
} else {
|
||||||
|
newStatus = monitor.status;
|
||||||
|
}
|
||||||
|
|
||||||
let statusChanged = false;
|
let statusChanged = false;
|
||||||
|
|
||||||
// First evaluate reachability-based status changes, which apply to all monitor types and take precedence over hardware breaches.
|
// First evaluate reachability-based status changes, which apply to all monitor types and take precedence over hardware breaches.
|
||||||
const reachabilityResult = this.computeReachability(monitor.status, monitor.statusWindow, monitor.statusWindowThreshold);
|
const reachabilityResult = this.computeReachability(newStatus, monitor.statusWindow, monitor.statusWindowThreshold);
|
||||||
if (reachabilityResult.transitioned) {
|
if (reachabilityResult.transitioned) {
|
||||||
newStatus = reachabilityResult.nextStatus;
|
newStatus = reachabilityResult.nextStatus;
|
||||||
statusChanged = true;
|
statusChanged = true;
|
||||||
@@ -273,7 +279,7 @@ export class StatusService implements IStatusService {
|
|||||||
const hardwarePayload = statusResponse.payload as HardwareStatusPayload | undefined;
|
const hardwarePayload = statusResponse.payload as HardwareStatusPayload | undefined;
|
||||||
if (monitor.type === "hardware" && hardwarePayload?.data) {
|
if (monitor.type === "hardware" && hardwarePayload?.data) {
|
||||||
const hardware = this.computeHardwareStatus({
|
const hardware = this.computeHardwareStatus({
|
||||||
currentStatus: monitor.status,
|
currentStatus: newStatus,
|
||||||
reachabilityDown: newStatus === "down",
|
reachabilityDown: newStatus === "down",
|
||||||
metrics: hardwarePayload.data,
|
metrics: hardwarePayload.data,
|
||||||
thresholds: {
|
thresholds: {
|
||||||
|
|||||||
Reference in new issue
Block a user