Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
update debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
zemberdotnet committed May 14, 2024
1 parent c5c970c commit e09ebdc
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/steps/vulnerabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export async function fetchAssetVulnerabilityFindings(
);

const debugCounts = {
processedAssets: 0,
findings: 0,
vulnerabilities: 0,
finding_is_vulnerability: 0,
Expand All @@ -131,6 +132,20 @@ export async function fetchAssetVulnerabilityFindings(
await jobState.iterateEntities(
{ _type: entities.ASSET._type },
async (assetEntity) => {
debugCounts.processedAssets++;
if (debugCounts.processedAssets % 1000 === 0) {
require('v8').writeHeapSnapshot();

logger.info(
{
memoryUsage: getMemoryUsage(),
debugCounts: debugCounts,
processedVulnerabilities,
},
'Memory usage',
);
}

const rawData = getRawData<InsightVMAsset>(assetEntity);
if (!rawData) {
throw new IntegrationMissingKeyError(
Expand Down Expand Up @@ -211,16 +226,6 @@ export async function fetchAssetVulnerabilityFindings(
debugCounts.finding_is_vulnerability++;

processedVulnerabilities++;
if (processedVulnerabilities % 250 === 0) {
logger.info(
{
memoryUsage: getMemoryUsage(),
debugCounts: debugCounts,
processedVulnerabilities,
},
'Memory usage',
);
}
}
},
);
Expand Down

0 comments on commit e09ebdc

Please sign in to comment.