diff --git a/lib/init-action.js b/lib/init-action.js index d459cf358..e267eaab2 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -89639,7 +89639,11 @@ async function initConfig(features, inputs) { } if (await features.getValue("ignore_generated_files" /* IgnoreGeneratedFiles */) && isCCR()) { try { + const generatedFilesCheckStartedAt = import_perf_hooks.performance.now(); const generatedFiles = await getGeneratedFiles(inputs.sourceRoot); + const generatedFilesDuration = Math.round( + import_perf_hooks.performance.now() - generatedFilesCheckStartedAt + ); if (generatedFiles.length > 0) { config.computedConfig["paths-ignore"] ??= []; config.computedConfig["paths-ignore"].push(...generatedFiles); @@ -89649,6 +89653,11 @@ async function initConfig(features, inputs) { } else { logger.info(`Found no generated files.`); } + await logGeneratedFilesTelemetry( + config, + generatedFilesDuration, + generatedFiles.length + ); } catch (error3) { logger.info(`Cannot ignore generated files: ${getErrorMessage(error3)}`); } @@ -89884,6 +89893,25 @@ async function logGitVersionTelemetry(config, gitVersion) { ); } } +async function logGeneratedFilesTelemetry(config, duration, generatedFilesCount) { + if (config.languages.length < 1) { + return; + } + addDiagnostic( + config, + // Arbitrarily choose the first language. We could also choose all languages, but that + // increases the risk of misinterpreting the data. + config.languages[0], + makeTelemetryDiagnostic( + "codeql-action/generated-files-telemetry", + "Generated files telemetry", + { + duration, + generatedFilesCount + } + ) + ); +} // src/dependency-caching.ts var os3 = __toESM(require("os")); diff --git a/src/config-utils.ts b/src/config-utils.ts index a77366991..772c187b8 100644 --- a/src/config-utils.ts +++ b/src/config-utils.ts @@ -959,7 +959,11 @@ export async function initConfig( // the `paths-ignore` configuration. if ((await features.getValue(Feature.IgnoreGeneratedFiles)) && isCCR()) { try { + const generatedFilesCheckStartedAt = performance.now(); const generatedFiles = await getGeneratedFiles(inputs.sourceRoot); + const generatedFilesDuration = Math.round( + performance.now() - generatedFilesCheckStartedAt, + ); if (generatedFiles.length > 0) { config.computedConfig["paths-ignore"] ??= []; @@ -970,6 +974,12 @@ export async function initConfig( } else { logger.info(`Found no generated files.`); } + + await logGeneratedFilesTelemetry( + config, + generatedFilesDuration, + generatedFiles.length, + ); } catch (error) { logger.info(`Cannot ignore generated files: ${getErrorMessage(error)}`); } @@ -1414,3 +1424,32 @@ async function logGitVersionTelemetry( ); } } + +/** + * Logs the time it took to identify generated files and how many were discovered as + * a telemetry diagnostic. + * */ +async function logGeneratedFilesTelemetry( + config: Config, + duration: number, + generatedFilesCount: number, +): Promise { + if (config.languages.length < 1) { + return; + } + + addDiagnostic( + config, + // Arbitrarily choose the first language. We could also choose all languages, but that + // increases the risk of misinterpreting the data. + config.languages[0], + makeTelemetryDiagnostic( + "codeql-action/generated-files-telemetry", + "Generated files telemetry", + { + duration, + generatedFilesCount, + }, + ), + ); +}