mirror of
https://github.com/github/codeql-action.git
synced 2026-04-07 12:42:27 +00:00
Add telemetry diagnostic
This commit is contained in:
28
lib/init-action.js
generated
28
lib/init-action.js
generated
@@ -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"));
|
||||
|
||||
@@ -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<void> {
|
||||
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,
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user