Skip to content

Commit dbb896a

Browse files
committed
feat: log the size of the different work queues every 15 minutes
When the Monitor has a lot of work to do, the queues fill up and it's hard to understand their size and progress. For customers with larger clusters it can be very helpful to have some visibility into the queue sizes. Logging an additional single line every 15 minutes, even if the queues are empty, should be more helpful than noisy.
1 parent 89b7f72 commit dbb896a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

config.default.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"WORKLOADS_TO_SCAN_QUEUE_WORKER_COUNT": 10,
1515
"METADATA_TO_SEND_QUEUE_WORKER_COUNT": 10,
16+
"QUEUE_LENGTH_LOG_FREQUENCY_MINUTES": 15,
1617
"INTEGRATION_ID": "",
1718
"DEFAULT_KUBERNETES_UPSTREAM_URL": "https://kubernetes-upstream.snyk.io"
1819
}

src/supervisor/watchers/handlers/pod.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ metadataToSendQueue.error(function(err, task) {
5454
logger.error({err, task}, 'error processing a workload metadata send task');
5555
});
5656

57+
setInterval(() => {
58+
try {
59+
const queueDataToReport: {[key: string]: any} = {};
60+
queueDataToReport.workloadsToScanLength = workloadsToScanQueue.length();
61+
queueDataToReport.metadataToSendLength = metadataToSendQueue.length();
62+
logger.info(queueDataToReport, 'queue sizes report');
63+
} catch (err) {
64+
logger.warn({err}, 'failed logging queue sizes');
65+
}
66+
}, config.QUEUE_LENGTH_LOG_FREQUENCY_MINUTES * 60 * 1000).unref();
67+
5768
function handleReadyPod(workloadMetadata: IWorkload[]): void {
5869
const imagesToScan: IWorkload[] = [];
5970
const imageKeys: string[] = [];

0 commit comments

Comments
 (0)