Telemetry: Record DB creation time
This commit is contained in:
parent
e7d4da3fa2
commit
8b45ef3845
8 changed files with 63 additions and 16 deletions
|
|
@ -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