Telemetry: Record DB creation time
This commit is contained in:
parent
e7d4da3fa2
commit
8b45ef3845
8 changed files with 63 additions and 16 deletions
|
|
@ -623,6 +623,11 @@ export interface StatusReportBase {
|
|||
codeql_version?: string;
|
||||
}
|
||||
|
||||
export interface DatabaseCreationTimings {
|
||||
scanned_language_extraction_duration_ms?: number;
|
||||
trap_import_duration_ms?: number;
|
||||
}
|
||||
|
||||
export function getActionsStatus(
|
||||
error?: unknown,
|
||||
otherFailureCause?: string
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { performance } from "perf_hooks";
|
|||
import * as core from "@actions/core";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import { DatabaseCreationTimings } from "./actions-util";
|
||||
import {
|
||||
CodeQLAnalysisError,
|
||||
QueriesStatusReport,
|
||||
|
|
@ -32,6 +33,7 @@ interface AnalysisStatusReport
|
|||
|
||||
interface FinishStatusReport
|
||||
extends actionsUtil.StatusReportBase,
|
||||
actionsUtil.DatabaseCreationTimings,
|
||||
AnalysisStatusReport {}
|
||||
|
||||
interface FinishWithTrapUploadStatusReport extends FinishStatusReport {
|
||||
|
|
@ -47,6 +49,7 @@ export async function sendStatusReport(
|
|||
stats: AnalysisStatusReport | undefined,
|
||||
error: Error | undefined,
|
||||
trapCacheUploadTime: number | undefined,
|
||||
dbCreationTimings: DatabaseCreationTimings | undefined,
|
||||
didUploadTrapCaches: boolean,
|
||||
logger: Logger
|
||||
) {
|
||||
|
|
@ -70,6 +73,7 @@ export async function sendStatusReport(
|
|||
}
|
||||
: {}),
|
||||
...(stats || {}),
|
||||
...(dbCreationTimings || {}),
|
||||
};
|
||||
if (config && didUploadTrapCaches) {
|
||||
const trapCacheUploadStatusReport: FinishWithTrapUploadStatusReport = {
|
||||
|
|
@ -99,6 +103,7 @@ async function run() {
|
|||
let runStats: QueriesStatusReport | undefined = undefined;
|
||||
let config: Config | undefined = undefined;
|
||||
let trapCacheUploadTime: number | undefined = undefined;
|
||||
let dbCreationTimings: DatabaseCreationTimings | undefined = undefined;
|
||||
let didUploadTrapCaches = false;
|
||||
util.initializeEnvironment(util.Mode.actions, pkg.version);
|
||||
await util.checkActionVersion(pkg.version);
|
||||
|
|
@ -161,7 +166,14 @@ async function run() {
|
|||
logger
|
||||
);
|
||||
|
||||
await runFinalize(outputDir, threads, memory, config, logger, featureFlags);
|
||||
dbCreationTimings = await runFinalize(
|
||||
outputDir,
|
||||
threads,
|
||||
memory,
|
||||
config,
|
||||
logger,
|
||||
featureFlags
|
||||
);
|
||||
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
||||
runStats = await runQueries(
|
||||
outputDir,
|
||||
|
|
@ -249,6 +261,7 @@ async function run() {
|
|||
stats,
|
||||
error,
|
||||
trapCacheUploadTime,
|
||||
dbCreationTimings,
|
||||
didUploadTrapCaches,
|
||||
logger
|
||||
);
|
||||
|
|
@ -259,6 +272,7 @@ async function run() {
|
|||
undefined,
|
||||
error,
|
||||
trapCacheUploadTime,
|
||||
dbCreationTimings,
|
||||
didUploadTrapCaches,
|
||||
logger
|
||||
);
|
||||
|
|
@ -277,6 +291,7 @@ async function run() {
|
|||
},
|
||||
undefined,
|
||||
trapCacheUploadTime,
|
||||
dbCreationTimings,
|
||||
didUploadTrapCaches,
|
||||
logger
|
||||
);
|
||||
|
|
@ -287,6 +302,7 @@ async function run() {
|
|||
{ ...runStats },
|
||||
undefined,
|
||||
trapCacheUploadTime,
|
||||
dbCreationTimings,
|
||||
didUploadTrapCaches,
|
||||
logger
|
||||
);
|
||||
|
|
@ -297,6 +313,7 @@ async function run() {
|
|||
undefined,
|
||||
undefined,
|
||||
trapCacheUploadTime,
|
||||
dbCreationTimings,
|
||||
didUploadTrapCaches,
|
||||
logger
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import { performance } from "perf_hooks"; // We need to import `performance` on Node 12
|
||||
|
||||
import * as toolrunner from "@actions/exec/lib/toolrunner";
|
||||
import del from "del";
|
||||
import * as yaml from "js-yaml";
|
||||
|
||||
import { DatabaseCreationTimings } from "./actions-util";
|
||||
import * as analysisPaths from "./analysis-paths";
|
||||
import {
|
||||
CodeQL,
|
||||
|
|
@ -168,10 +170,14 @@ async function finalizeDatabaseCreation(
|
|||
memoryFlag: string,
|
||||
logger: Logger,
|
||||
featureFlags: FeatureFlags
|
||||
) {
|
||||
): Promise<DatabaseCreationTimings> {
|
||||
const codeql = await getCodeQL(config.codeQLCmd);
|
||||
await createdDBForScannedLanguages(codeql, config, logger, featureFlags);
|
||||
|
||||
const extractionStart = performance.now();
|
||||
await createdDBForScannedLanguages(codeql, config, logger, featureFlags);
|
||||
const extractionTime = performance.now() - extractionStart;
|
||||
|
||||
const trapImportStart = performance.now();
|
||||
for (const language of config.languages) {
|
||||
if (dbIsFinalized(config, language, logger)) {
|
||||
logger.info(
|
||||
|
|
@ -187,6 +193,12 @@ async function finalizeDatabaseCreation(
|
|||
logger.endGroup();
|
||||
}
|
||||
}
|
||||
const trapImportTime = performance.now() - trapImportStart;
|
||||
|
||||
return {
|
||||
scanned_language_extraction_duration_ms: Math.round(extractionTime),
|
||||
trap_import_duration_ms: Math.round(trapImportTime),
|
||||
};
|
||||
}
|
||||
|
||||
// Runs queries and creates sarif files in the given folder
|
||||
|
|
@ -496,7 +508,7 @@ export async function runFinalize(
|
|||
config: configUtils.Config,
|
||||
logger: Logger,
|
||||
featureFlags: FeatureFlags
|
||||
) {
|
||||
): Promise<DatabaseCreationTimings> {
|
||||
try {
|
||||
await del(outputDir, { force: true });
|
||||
} catch (error: any) {
|
||||
|
|
@ -506,7 +518,7 @@ export async function runFinalize(
|
|||
}
|
||||
await fs.promises.mkdir(outputDir, { recursive: true });
|
||||
|
||||
await finalizeDatabaseCreation(
|
||||
const timings = await finalizeDatabaseCreation(
|
||||
config,
|
||||
threadsFlag,
|
||||
memoryFlag,
|
||||
|
|
@ -527,6 +539,7 @@ export async function runFinalize(
|
|||
// Delete the tracer config env var to avoid tracing ourselves
|
||||
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
|
||||
}
|
||||
return timings;
|
||||
}
|
||||
|
||||
export async function runCleanup(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue