Skip to content

Commit 2f50c1c

Browse files
author
Amir Moualem
authored
Merge pull request #663 from snyk/feat/queue-size-log
feat: log the size of the different work queues every 15 minutes
2 parents 89b7f72 + dbb896a commit 2f50c1c

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)