Skip to content

Commit

Permalink
Telemetry: Record DB creation time
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardopirovano committed Aug 24, 2022
1 parent e7d4da3 commit 4a41610
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
16 changes: 10 additions & 6 deletions lib/analyze-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analyze-action.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion src/analyze-action.ts
Expand Up @@ -32,7 +32,9 @@ interface AnalysisStatusReport

interface FinishStatusReport
extends actionsUtil.StatusReportBase,
AnalysisStatusReport {}
AnalysisStatusReport {
db_creation_duration_ms: number;
}

interface FinishWithTrapUploadStatusReport extends FinishStatusReport {
/** Size of TRAP caches that we uploaded, in bytes. */
Expand All @@ -47,6 +49,7 @@ export async function sendStatusReport(
stats: AnalysisStatusReport | undefined,
error: Error | undefined,
trapCacheUploadTime: number | undefined,
dbCreationTime: number | undefined,
didUploadTrapCaches: boolean,
logger: Logger
) {
Expand All @@ -70,6 +73,7 @@ export async function sendStatusReport(
}
: {}),
...(stats || {}),
db_creation_duration_ms: Math.round(dbCreationTime || 0),
};
if (config && didUploadTrapCaches) {
const trapCacheUploadStatusReport: FinishWithTrapUploadStatusReport = {
Expand Down Expand Up @@ -99,6 +103,7 @@ async function run() {
let runStats: QueriesStatusReport | undefined = undefined;
let config: Config | undefined = undefined;
let trapCacheUploadTime: number | undefined = undefined;
let dbCreationTime: number | undefined = undefined;
let didUploadTrapCaches = false;
util.initializeEnvironment(util.Mode.actions, pkg.version);
await util.checkActionVersion(pkg.version);
Expand Down Expand Up @@ -161,7 +166,9 @@ async function run() {
logger
);

const dbCreationStartTime = performance.now();
await runFinalize(outputDir, threads, memory, config, logger, featureFlags);
dbCreationTime = performance.now() - dbCreationStartTime;
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
runStats = await runQueries(
outputDir,
Expand Down Expand Up @@ -249,6 +256,7 @@ async function run() {
stats,
error,
trapCacheUploadTime,
dbCreationTime,
didUploadTrapCaches,
logger
);
Expand All @@ -259,6 +267,7 @@ async function run() {
undefined,
error,
trapCacheUploadTime,
dbCreationTime,
didUploadTrapCaches,
logger
);
Expand All @@ -277,6 +286,7 @@ async function run() {
},
undefined,
trapCacheUploadTime,
dbCreationTime,
didUploadTrapCaches,
logger
);
Expand All @@ -287,6 +297,7 @@ async function run() {
{ ...runStats },
undefined,
trapCacheUploadTime,
dbCreationTime,
didUploadTrapCaches,
logger
);
Expand All @@ -297,6 +308,7 @@ async function run() {
undefined,
undefined,
trapCacheUploadTime,
dbCreationTime,
didUploadTrapCaches,
logger
);
Expand Down

0 comments on commit 4a41610

Please sign in to comment.