Address code review feedback: fix typo and prevent overlapping executions

- Fix spelling: 'retrived' -> 'retrieved' in proxysessionmetrics.js
- Add flag to prevent overlapping health check executions
- Change back to sequential server processing to avoid overwhelming Sense servers
- Add warning log when skipping intervals due to long-running health checks

Co-authored-by: mountaindude <1029262+mountaindude@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-18 06:14:27 +00:00
parent c444156871
commit 17f20985ca
2 changed files with 35 additions and 20 deletions

View File

@@ -156,18 +156,33 @@ export async function getHealthStatsFromSense(serverName, host, tags, headers, r
*
* This function creates an interval that runs every pollingInterval milliseconds (as defined in config)
* and calls getHealthStatsFromSense for each server in the serverList global variable.
* Uses a flag to prevent overlapping executions if health checks take longer than the polling interval.
*
* @returns {void}
*/
export function setupHealthMetricsTimer() {
let isCollecting = false;
// Configure timer for getting healthcheck data
setInterval(async () => {
// Prevent overlapping executions
if (isCollecting) {
globals.logger.warn(
'HEALTH: Previous health check collection still in progress, skipping this interval'
);
return;
}
isCollecting = true;
try {
globals.logger.verbose('HEALTH: Event started: Statistics collection');
// Process all servers concurrently with error handling
const healthCheckPromises = globals.serverList.map(async (server) => {
// Process servers sequentially to avoid overwhelming the Sense servers
for (const server of globals.serverList) {
try {
globals.logger.verbose(`HEALTH: Getting stats for server: ${server.serverName}`);
globals.logger.verbose(
`HEALTH: Getting stats for server: ${server.serverName}`
);
globals.logger.debug(`HEALTH: Server details: ${JSON.stringify(server)}`);
// Get per-server tags
@@ -182,9 +197,9 @@ export function setupHealthMetricsTimer() {
`HEALTH: Unexpected error processing health stats for server '${server.serverName}': ${globals.getErrorMessage(err)}`
);
}
});
// Wait for all health checks to complete
await Promise.allSettled(healthCheckPromises);
}
} finally {
isCollecting = false;
}
}, globals.config.get('Butler-SOS.serversToMonitor.pollingInterval'));
}

View File

@@ -222,7 +222,7 @@ export async function getProxySessionStatsFromSense(
influxTags,
retryCount = 0
) {
// Current user sessions are retrived using this API:
// Current user sessions are retrieved using this API:
// https://help.qlik.com/en-US/sense-developer/February2021/Subsystems/ProxyServiceAPI/Content/Sense_ProxyServiceAPI/ProxyServiceAPI-Proxy-API.htm
// Get certificate configuration options