Do not use stringified objects for dependency caching telemetry

This commit is contained in:
Michael B. Gale
2025-09-26 00:26:09 +01:00
parent ed57767898
commit 31bfb99f0d
8 changed files with 36 additions and 49 deletions

17
lib/analyze-action.js generated
View File

@@ -93330,7 +93330,7 @@ async function makeGlobber(patterns) {
return glob.create(patterns.join("\n"));
}
async function uploadDependencyCaches(config, logger, minimizeJavaJars) {
const status = {};
const status = [];
for (const language of config.languages) {
const cacheConfig = getDefaultCacheConfig()[language];
if (cacheConfig === void 0) {
@@ -93341,7 +93341,7 @@ async function uploadDependencyCaches(config, logger, minimizeJavaJars) {
}
const globber = await makeGlobber(cacheConfig.hash);
if ((await globber.glob()).length === 0) {
status[language] = { result: "no-hash" /* NoHash */ };
status.push({ language, result: "no-hash" /* NoHash */ });
logger.info(
`Skipping upload of dependency cache for ${language} as we cannot calculate a hash for the cache key.`
);
@@ -93349,7 +93349,7 @@ async function uploadDependencyCaches(config, logger, minimizeJavaJars) {
}
const size = await getTotalCacheSize(cacheConfig.paths, logger, true);
if (size === 0) {
status[language] = { result: "empty" /* Empty */ };
status.push({ language, result: "empty" /* Empty */ });
logger.info(
`Skipping upload of dependency cache for ${language} since it is empty.`
);
@@ -93363,18 +93363,19 @@ async function uploadDependencyCaches(config, logger, minimizeJavaJars) {
const start = performance.now();
await actionsCache3.saveCache(cacheConfig.paths, key);
const upload_duration_ms = Math.round(performance.now() - start);
status[language] = {
status.push({
language,
result: "stored" /* Stored */,
upload_size_bytes: Math.round(size),
upload_duration_ms
};
});
} catch (error2) {
if (error2 instanceof actionsCache3.ReserveCacheError) {
logger.info(
`Not uploading cache for ${language}, because ${key} is already in use.`
);
logger.debug(error2.message);
status[language] = { result: "duplicate" /* Duplicate */ };
status.push({ language, result: "duplicate" /* Duplicate */ });
} else {
throw error2;
}
@@ -95963,9 +95964,7 @@ async function sendStatusReport2(startedAt, config, stats, error2, trapCacheUplo
...stats || {},
...dbCreationTimings || {},
...trapCacheCleanup || {},
dependency_caching_upload_results: JSON.stringify(
dependencyCacheResults ?? {}
)
dependency_caching_upload_results: dependencyCacheResults
};
if (config && didUploadTrapCaches) {
const trapCacheUploadStatusReport = {

View File

@@ -133803,7 +133803,7 @@ async function runWrapper() {
...statusReportBase,
...uploadFailedSarifResult,
job_status: getFinalJobStatus(),
dependency_caching_usage: JSON.stringify(dependencyCachingUsage ?? {})
dependency_caching_usage: dependencyCachingUsage
};
logger.info("Sending status report for init-post step.");
await sendStatusReport(statusReport);

15
lib/init-action.js generated
View File

@@ -88175,7 +88175,7 @@ async function makeGlobber(patterns) {
return glob.create(patterns.join("\n"));
}
async function downloadDependencyCaches(languages, logger, minimizeJavaJars) {
const status = {};
const status = [];
for (const language of languages) {
const cacheConfig = getDefaultCacheConfig()[language];
if (cacheConfig === void 0) {
@@ -88186,7 +88186,7 @@ async function downloadDependencyCaches(languages, logger, minimizeJavaJars) {
}
const globber = await makeGlobber(cacheConfig.hash);
if ((await globber.glob()).length === 0) {
status[language] = { hit_kind: "no-hash" /* NoHash */ };
status.push({ language, hit_kind: "no-hash" /* NoHash */ });
logger.info(
`Skipping download of dependency cache for ${language} as we cannot calculate a hash for the cache key.`
);
@@ -88211,12 +88211,9 @@ async function downloadDependencyCaches(languages, logger, minimizeJavaJars) {
if (hitKey !== void 0) {
logger.info(`Cache hit on key ${hitKey} for ${language}.`);
const hit_kind = hitKey === primaryKey ? "exact" /* Exact */ : "partial" /* Partial */;
status[language] = {
hit_kind,
download_duration_ms
};
status.push({ language, hit_kind, download_duration_ms });
} else {
status[language] = { hit_kind: "miss" /* Miss */ };
status.push({ language, hit_kind: "miss" /* Miss */ });
logger.info(`No suitable cache found for ${language}.`);
}
}
@@ -90361,9 +90358,7 @@ async function createInitWithConfigStatusReport(config, initStatusReport, config
trap_cache_download_duration_ms: Math.round(config.trapCacheDownloadTime),
overlay_base_database_download_size_bytes: overlayBaseDatabaseStats?.databaseSizeBytes,
overlay_base_database_download_duration_ms: overlayBaseDatabaseStats?.databaseDownloadDurationMs,
dependency_caching_restore_results: JSON.stringify(
dependencyCachingResults ?? {}
),
dependency_caching_restore_results: dependencyCachingResults,
query_filters: JSON.stringify(
config.originalUserInput["query-filters"] ?? []
),