Move download telemetry into the status-report directory

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Henry Mercer
2026-09-17 19:04:38 +01:00
parent ead1f7d93f
commit 79fe3a1270
6 changed files with 88 additions and 85 deletions

46
lib/entry-points.js generated
View File

@@ -147625,28 +147625,6 @@ async function sendStatusReport(statusReport) {
);
}
}
function createInitToolsDownloadFields(report, toolsFeatureFlagsValid) {
const fields = {};
if (report?.downloadDurationMs !== void 0) {
fields.tools_download_duration_ms = report.downloadDurationMs;
}
if (report?.extractionDurationMs !== void 0) {
fields.tools_extraction_duration_ms = report.extractionDurationMs;
}
if (report?.totalDurationMs !== void 0) {
fields.tools_total_duration_ms = report.totalDurationMs;
}
if (report?.bundleLanguage !== void 0) {
fields.tools_bundle_language = report.bundleLanguage;
}
if (report?.perLanguageBundleFallback !== void 0) {
fields.tools_per_language_bundle_fallback = report.perLanguageBundleFallback;
}
if (toolsFeatureFlagsValid !== void 0) {
fields.tools_feature_flags_valid = toolsFeatureFlagsValid;
}
return fields;
}
async function createInitWithConfigStatusReport(config, initStatusReport, configFile, totalCacheSize, overlayBaseDatabaseStats, dependencyCachingResults) {
const languages = config.languages.join(",");
const paths = (config.originalUserInput.paths || []).join(",");
@@ -161882,6 +161860,30 @@ async function getToolsInput(action, repositoryProperties) {
return void 0;
}
// src/status-report/tools-download.ts
function createInitToolsDownloadFields(report, toolsFeatureFlagsValid) {
const fields = {};
if (report?.downloadDurationMs !== void 0) {
fields.tools_download_duration_ms = report.downloadDurationMs;
}
if (report?.extractionDurationMs !== void 0) {
fields.tools_extraction_duration_ms = report.extractionDurationMs;
}
if (report?.totalDurationMs !== void 0) {
fields.tools_total_duration_ms = report.totalDurationMs;
}
if (report?.bundleLanguage !== void 0) {
fields.tools_bundle_language = report.bundleLanguage;
}
if (report?.perLanguageBundleFallback !== void 0) {
fields.tools_per_language_bundle_fallback = report.perLanguageBundleFallback;
}
if (toolsFeatureFlagsValid !== void 0) {
fields.tools_feature_flags_valid = toolsFeatureFlagsValid;
}
return fields;
}
// src/workflow.ts
var fs28 = __toESM(require("fs"));
var path24 = __toESM(require("path"));

View File

@@ -65,11 +65,11 @@ import {
InitStatusReport,
InitWithConfigStatusReport,
createInitWithConfigStatusReport,
createInitToolsDownloadFields,
createStatusReportBase,
getActionsStatus,
sendStatusReport,
} from "./status-report";
import { createInitToolsDownloadFields } from "./status-report/tools-download";
import { ToolsDownloadStatusReport } from "./tools-download";
import { ToolsFeature } from "./tools-features";
import { getCombinedTracerConfig } from "./tracer-config";

View File

@@ -22,11 +22,11 @@ import { ToolsSource } from "./setup-codeql";
import {
ActionName,
InitStatusReport,
createInitToolsDownloadFields,
createStatusReportBase,
getActionsStatus,
sendStatusReport,
} from "./status-report";
import { createInitToolsDownloadFields } from "./status-report/tools-download";
import { ToolsDownloadStatusReport } from "./tools-download";
import {
checkDiskUsage,

View File

@@ -31,7 +31,6 @@ import type { OverlayBaseDatabaseDownloadStats } from "./overlay/caching";
import { getRepositoryNwo } from "./repository";
import type { ToolsSource } from "./setup-codeql";
import { registryBaseSchema } from "./start-proxy/types";
import type { ToolsDownloadStatusReport } from "./tools-download";
import {
ConfigurationError,
getRequiredEnvParam,
@@ -625,64 +624,6 @@ export interface InitWithConfigStatusReport extends InitStatusReport {
config_file: string;
}
/** Fields of the init status report populated when the tools source is `download`. */
export interface InitToolsDownloadFields {
/**
* Time taken to download the bundle, in milliseconds. Not populated when the bundle is downloaded
* and extracted concurrently.
*/
tools_download_duration_ms?: ToolsDownloadStatusReport["downloadDurationMs"];
/**
* Time taken to extract the bundle, in milliseconds. Not populated when the bundle is downloaded
* and extracted concurrently.
*/
tools_extraction_duration_ms?: ToolsDownloadStatusReport["extractionDurationMs"];
/**
* Total time taken to make the bundle available on disk, including failed download attempts
* before a fallback, in milliseconds.
*/
tools_total_duration_ms?: ToolsDownloadStatusReport["totalDurationMs"];
/**
* Whether the relevant tools dotcom feature flags have been misconfigured.
* Only populated if we attempt to determine the default version based on the dotcom feature flags. */
tools_feature_flags_valid?: boolean;
/** The language of the single-language bundle that was downloaded, if any. */
tools_bundle_language?: ToolsDownloadStatusReport["bundleLanguage"];
/**
* Whether we tried to download a single-language bundle, but it did not exist and we fell back to
* the combined bundle.
*/
tools_per_language_bundle_fallback?: ToolsDownloadStatusReport["perLanguageBundleFallback"];
}
/** Converts download results to telemetry fields shared by the init and setup-codeql Actions. */
export function createInitToolsDownloadFields(
report: ToolsDownloadStatusReport | undefined,
toolsFeatureFlagsValid: boolean | undefined,
): InitToolsDownloadFields {
const fields: InitToolsDownloadFields = {};
if (report?.downloadDurationMs !== undefined) {
fields.tools_download_duration_ms = report.downloadDurationMs;
}
if (report?.extractionDurationMs !== undefined) {
fields.tools_extraction_duration_ms = report.extractionDurationMs;
}
if (report?.totalDurationMs !== undefined) {
fields.tools_total_duration_ms = report.totalDurationMs;
}
if (report?.bundleLanguage !== undefined) {
fields.tools_bundle_language = report.bundleLanguage;
}
if (report?.perLanguageBundleFallback !== undefined) {
fields.tools_per_language_bundle_fallback =
report.perLanguageBundleFallback;
}
if (toolsFeatureFlagsValid !== undefined) {
fields.tools_feature_flags_valid = toolsFeatureFlagsValid;
}
return fields;
}
/**
* Composes a `InitWithConfigStatusReport` from the given values.
*

View File

@@ -1,7 +1,8 @@
import test from "ava";
import { BuiltInLanguage } from "./languages";
import { createInitToolsDownloadFields } from "./status-report";
import { BuiltInLanguage } from "../languages";
import { createInitToolsDownloadFields } from "./tools-download";
test("createInitToolsDownloadFields omits absent download data", (t) => {
t.deepEqual(createInitToolsDownloadFields(undefined, undefined), {});

View File

@@ -0,0 +1,59 @@
import type { ToolsDownloadStatusReport } from "../tools-download";
/** Fields of the init status report populated when the tools source is `download`. */
export interface InitToolsDownloadFields {
/**
* Time taken to download the bundle, in milliseconds. Not populated when the bundle is downloaded
* and extracted concurrently.
*/
tools_download_duration_ms?: ToolsDownloadStatusReport["downloadDurationMs"];
/**
* Time taken to extract the bundle, in milliseconds. Not populated when the bundle is downloaded
* and extracted concurrently.
*/
tools_extraction_duration_ms?: ToolsDownloadStatusReport["extractionDurationMs"];
/**
* Total time taken to make the bundle available on disk, including failed download attempts
* before a fallback, in milliseconds.
*/
tools_total_duration_ms?: ToolsDownloadStatusReport["totalDurationMs"];
/**
* Whether the relevant tools dotcom feature flags have been misconfigured.
* Only populated if we attempt to determine the default version based on the dotcom feature flags. */
tools_feature_flags_valid?: boolean;
/** The language of the single-language bundle that was downloaded, if any. */
tools_bundle_language?: ToolsDownloadStatusReport["bundleLanguage"];
/**
* Whether we tried to download a single-language bundle, but it did not exist and we fell back to
* the combined bundle.
*/
tools_per_language_bundle_fallback?: ToolsDownloadStatusReport["perLanguageBundleFallback"];
}
/** Converts download results to telemetry fields shared by the init and setup-codeql Actions. */
export function createInitToolsDownloadFields(
report: ToolsDownloadStatusReport | undefined,
toolsFeatureFlagsValid: boolean | undefined,
): InitToolsDownloadFields {
const fields: InitToolsDownloadFields = {};
if (report?.downloadDurationMs !== undefined) {
fields.tools_download_duration_ms = report.downloadDurationMs;
}
if (report?.extractionDurationMs !== undefined) {
fields.tools_extraction_duration_ms = report.extractionDurationMs;
}
if (report?.totalDurationMs !== undefined) {
fields.tools_total_duration_ms = report.totalDurationMs;
}
if (report?.bundleLanguage !== undefined) {
fields.tools_bundle_language = report.bundleLanguage;
}
if (report?.perLanguageBundleFallback !== undefined) {
fields.tools_per_language_bundle_fallback =
report.perLanguageBundleFallback;
}
if (toolsFeatureFlagsValid !== undefined) {
fields.tools_feature_flags_valid = toolsFeatureFlagsValid;
}
return fields;
}