Skip to content

Commit ecec9b5

Browse files
henrymercerCopilot
andcommitted
Share per-language telemetry fields without renaming
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 79fe3a1 commit ecec9b5

6 files changed

Lines changed: 45 additions & 47 deletions

File tree

lib/entry-points.js

Lines changed: 6 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/setup-codeql.test.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ for (const bundlePath of [
557557
t.is(result.toolsVersion, "unknown");
558558
t.is(result.toolsSource, setupCodeql.ToolsSource.Download);
559559
t.is(
560-
result.toolsDownloadStatusReport?.bundleLanguage,
560+
result.toolsDownloadStatusReport?.perLanguage?.tools_bundle_language,
561561
bundlePath === "codeql-bundle-ruby-linux64.tar.zst"
562562
? BuiltInLanguage.ruby
563563
: undefined,
@@ -1309,11 +1309,12 @@ for (const fallback of [false, true]) {
13091309
t.is(extractStub.lastCall.args[3], "token token");
13101310
t.is(result.toolsVersion, MIN_PER_LANGUAGE_BUNDLE_CLI_VERSION);
13111311
t.is(
1312-
result.toolsDownloadStatusReport?.bundleLanguage,
1312+
result.toolsDownloadStatusReport?.perLanguage?.tools_bundle_language,
13131313
fallback ? undefined : BuiltInLanguage.java,
13141314
);
13151315
t.is(
1316-
result.toolsDownloadStatusReport?.perLanguageBundleFallback,
1316+
result.toolsDownloadStatusReport?.perLanguage
1317+
?.tools_per_language_bundle_fallback,
13171318
fallback ? true : undefined,
13181319
);
13191320
if (fallback) {
@@ -1401,7 +1402,8 @@ for (const bundle of ["per-language", "combined", "fallback"] as const) {
14011402
t.is(result.toolsDownloadStatusReport?.downloadDurationMs, 200);
14021403
t.is(result.toolsDownloadStatusReport?.extractionDurationMs, 100);
14031404
t.is(
1404-
(await downloadSpy.lastCall.returnValue).statusReport.bundleLanguage,
1405+
(await downloadSpy.lastCall.returnValue).statusReport.perLanguage
1406+
?.tools_bundle_language,
14051407
bundle === "per-language" ? BuiltInLanguage.javascript : undefined,
14061408
);
14071409
t.is(extractStub.callCount, bundle === "fallback" ? 2 : 1);
@@ -1415,11 +1417,12 @@ for (const bundle of ["per-language", "combined", "fallback"] as const) {
14151417
bundle === "per-language" ? perLanguageURL : combinedURL,
14161418
);
14171419
t.is(
1418-
result.toolsDownloadStatusReport?.bundleLanguage,
1420+
result.toolsDownloadStatusReport?.perLanguage?.tools_bundle_language,
14191421
bundle === "per-language" ? BuiltInLanguage.javascript : undefined,
14201422
);
14211423
t.is(
1422-
result.toolsDownloadStatusReport?.perLanguageBundleFallback,
1424+
result.toolsDownloadStatusReport?.perLanguage
1425+
?.tools_per_language_bundle_fallback,
14231426
bundle === "fallback" ? true : undefined,
14241427
);
14251428
t.is(
@@ -1503,7 +1506,7 @@ for (const asset of [
15031506
t.is(extractStub.firstCall.args[0], url);
15041507
t.is(result.toolsVersion, "9.9.9");
15051508
t.is(
1506-
result.toolsDownloadStatusReport?.bundleLanguage,
1509+
result.toolsDownloadStatusReport?.perLanguage?.tools_bundle_language,
15071510
BuiltInLanguage.ruby,
15081511
);
15091512
t.is(path.dirname(result.codeqlFolder), tmpDir);

src/setup-codeql.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,10 @@ export const downloadCodeQL = async function (
904904
codeqlFolder: extractedBundlePath,
905905
statusReport:
906906
bundle.kind === "per-language"
907-
? { ...statusReport, bundleLanguage: bundle.language }
907+
? {
908+
...statusReport,
909+
perLanguage: { tools_bundle_language: bundle.language },
910+
}
908911
: statusReport,
909912
};
910913
};
@@ -1171,7 +1174,7 @@ export async function downloadCodeQLBundle(
11711174
statusReport: {
11721175
...result.statusReport,
11731176
totalDurationMs: util.durationMsSince(startTime),
1174-
perLanguageBundleFallback: true,
1177+
perLanguage: { tools_per_language_bundle_fallback: true },
11751178
},
11761179
};
11771180
}

src/status-report/tools-download.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ test("createInitToolsDownloadFields reports only the total for a streaming downl
2424
test("createInitToolsDownloadFields preserves per-language metadata", (t) => {
2525
t.deepEqual(
2626
createInitToolsDownloadFields(
27-
{ totalDurationMs: 300, bundleLanguage: BuiltInLanguage.java },
27+
{
28+
totalDurationMs: 300,
29+
perLanguage: { tools_bundle_language: BuiltInLanguage.java },
30+
},
2831
true,
2932
),
3033
{
@@ -42,7 +45,7 @@ test("createInitToolsDownloadFields preserves fallback and per-attempt timings",
4245
downloadDurationMs: 200,
4346
extractionDurationMs: 100,
4447
totalDurationMs: 1000,
45-
perLanguageBundleFallback: true,
48+
perLanguage: { tools_per_language_bundle_fallback: true },
4649
},
4750
undefined,
4851
),
@@ -62,7 +65,7 @@ test("createInitToolsDownloadFields preserves zero durations and false flags", (
6265
downloadDurationMs: 0,
6366
extractionDurationMs: 0,
6467
totalDurationMs: 0,
65-
perLanguageBundleFallback: false,
68+
perLanguage: { tools_per_language_bundle_fallback: false },
6669
},
6770
false,
6871
),

src/status-report/tools-download.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,45 @@
11
import type { ToolsDownloadStatusReport } from "../tools-download";
22

3+
/** Telemetry describing per-language bundle downloads. */
4+
export interface PerLanguageToolsStatusReport {
5+
/** The language of the single-language bundle that was downloaded, if any. */
6+
tools_bundle_language?: string;
7+
/**
8+
* Whether we tried to download a single-language bundle, but it did not exist and we fell back to
9+
* the combined bundle.
10+
*/
11+
tools_per_language_bundle_fallback?: boolean;
12+
}
13+
314
/** Fields of the init status report populated when the tools source is `download`. */
4-
export interface InitToolsDownloadFields {
15+
export interface InitToolsDownloadFields extends PerLanguageToolsStatusReport {
516
/**
617
* Time taken to download the bundle, in milliseconds. Not populated when the bundle is downloaded
718
* and extracted concurrently.
819
*/
9-
tools_download_duration_ms?: ToolsDownloadStatusReport["downloadDurationMs"];
20+
tools_download_duration_ms?: number;
1021
/**
1122
* Time taken to extract the bundle, in milliseconds. Not populated when the bundle is downloaded
1223
* and extracted concurrently.
1324
*/
14-
tools_extraction_duration_ms?: ToolsDownloadStatusReport["extractionDurationMs"];
25+
tools_extraction_duration_ms?: number;
1526
/**
1627
* Total time taken to make the bundle available on disk, including failed download attempts
1728
* before a fallback, in milliseconds.
1829
*/
19-
tools_total_duration_ms?: ToolsDownloadStatusReport["totalDurationMs"];
30+
tools_total_duration_ms?: number;
2031
/**
2132
* Whether the relevant tools dotcom feature flags have been misconfigured.
2233
* Only populated if we attempt to determine the default version based on the dotcom feature flags. */
2334
tools_feature_flags_valid?: boolean;
24-
/** The language of the single-language bundle that was downloaded, if any. */
25-
tools_bundle_language?: ToolsDownloadStatusReport["bundleLanguage"];
26-
/**
27-
* Whether we tried to download a single-language bundle, but it did not exist and we fell back to
28-
* the combined bundle.
29-
*/
30-
tools_per_language_bundle_fallback?: ToolsDownloadStatusReport["perLanguageBundleFallback"];
3135
}
3236

3337
/** Converts download results to telemetry fields shared by the init and setup-codeql Actions. */
3438
export function createInitToolsDownloadFields(
3539
report: ToolsDownloadStatusReport | undefined,
3640
toolsFeatureFlagsValid: boolean | undefined,
3741
): InitToolsDownloadFields {
38-
const fields: InitToolsDownloadFields = {};
42+
const fields: InitToolsDownloadFields = { ...report?.perLanguage };
3943
if (report?.downloadDurationMs !== undefined) {
4044
fields.tools_download_duration_ms = report.downloadDurationMs;
4145
}
@@ -45,13 +49,6 @@ export function createInitToolsDownloadFields(
4549
if (report?.totalDurationMs !== undefined) {
4650
fields.tools_total_duration_ms = report.totalDurationMs;
4751
}
48-
if (report?.bundleLanguage !== undefined) {
49-
fields.tools_bundle_language = report.bundleLanguage;
50-
}
51-
if (report?.perLanguageBundleFallback !== undefined) {
52-
fields.tools_per_language_bundle_fallback =
53-
report.perLanguageBundleFallback;
54-
}
5552
if (toolsFeatureFlagsValid !== undefined) {
5653
fields.tools_feature_flags_valid = toolsFeatureFlagsValid;
5754
}

src/tools-download.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import * as semver from "semver";
1313
import { ActionState } from "./action-common";
1414
import { ActionsEnvVars, getEnv, ReadOnlyEnv } from "./environment";
1515
import { formatDuration, Logger } from "./logging";
16+
import type { PerLanguageToolsStatusReport } from "./status-report/tools-download";
1617
import * as tar from "./tar";
1718
import {
1819
asHTTPError,
@@ -55,13 +56,7 @@ export type ToolsDownloadStatusReport = {
5556
* before a fallback, in milliseconds.
5657
*/
5758
totalDurationMs: number;
58-
/** The language of the single-language bundle that was downloaded, if any. */
59-
bundleLanguage?: string;
60-
/**
61-
* Whether we tried to download a single-language bundle, but it did not exist and we fell back to
62-
* the combined bundle.
63-
*/
64-
perLanguageBundleFallback?: boolean;
59+
perLanguage?: PerLanguageToolsStatusReport;
6560
};
6661

6762
export async function downloadAndExtract(

0 commit comments

Comments
 (0)