@@ -959,7 +959,11 @@ export async function initConfig(
959959 // the `paths-ignore` configuration.
960960 if ( ( await features . getValue ( Feature . IgnoreGeneratedFiles ) ) && isCCR ( ) ) {
961961 try {
962+ const generatedFilesCheckStartedAt = performance . now ( ) ;
962963 const generatedFiles = await getGeneratedFiles ( inputs . sourceRoot ) ;
964+ const generatedFilesDuration = Math . round (
965+ performance . now ( ) - generatedFilesCheckStartedAt ,
966+ ) ;
963967
964968 if ( generatedFiles . length > 0 ) {
965969 config . computedConfig [ "paths-ignore" ] ??= [ ] ;
@@ -970,6 +974,12 @@ export async function initConfig(
970974 } else {
971975 logger . info ( `Found no generated files.` ) ;
972976 }
977+
978+ await logGeneratedFilesTelemetry (
979+ config ,
980+ generatedFilesDuration ,
981+ generatedFiles . length ,
982+ ) ;
973983 } catch ( error ) {
974984 logger . info ( `Cannot ignore generated files: ${ getErrorMessage ( error ) } ` ) ;
975985 }
@@ -1414,3 +1424,32 @@ async function logGitVersionTelemetry(
14141424 ) ;
14151425 }
14161426}
1427+
1428+ /**
1429+ * Logs the time it took to identify generated files and how many were discovered as
1430+ * a telemetry diagnostic.
1431+ * */
1432+ async function logGeneratedFilesTelemetry (
1433+ config : Config ,
1434+ duration : number ,
1435+ generatedFilesCount : number ,
1436+ ) : Promise < void > {
1437+ if ( config . languages . length < 1 ) {
1438+ return ;
1439+ }
1440+
1441+ addDiagnostic (
1442+ config ,
1443+ // Arbitrarily choose the first language. We could also choose all languages, but that
1444+ // increases the risk of misinterpreting the data.
1445+ config . languages [ 0 ] ,
1446+ makeTelemetryDiagnostic (
1447+ "codeql-action/generated-files-telemetry" ,
1448+ "Generated files telemetry" ,
1449+ {
1450+ duration,
1451+ generatedFilesCount,
1452+ } ,
1453+ ) ,
1454+ ) ;
1455+ }
0 commit comments