diff --git a/src/daemon/processWatcher.ts b/src/daemon/processWatcher.ts index ff1f580f..9e8c1b7f 100644 --- a/src/daemon/processWatcher.ts +++ b/src/daemon/processWatcher.ts @@ -9,6 +9,7 @@ import { promisify } from "util"; import * as vscode from "vscode"; import { sendInfo } from "vscode-extension-telemetry-wrapper"; import { LSDaemon } from "./daemon"; +import { activatingTimestamp } from "../extension"; const execFile = promisify(cp.execFile); interface IJdtlsMetadata { @@ -59,6 +60,9 @@ export class ProcessWatcher { public monitor() { const id = setInterval(() => { this.upTime().then(seconds => { + if (!this.lastHeartbeat && seconds) { + this.sendClientInitializeTime(seconds); + } this.lastHeartbeat = seconds; }).catch(_e => { clearInterval(id); @@ -99,6 +103,23 @@ export class ProcessWatcher { }); this.daemon.logWatcher.sendErrorAndStackOnCrash(); } + + /** + * Send the time the client takes to initialize. This is the time between the + * activation and the JVM process is launched. + */ + private sendClientInitializeTime(seconds: string) { + const upTime = seconds.match(/\d+\.\d+/)?.toString(); + if (upTime) { + let interval = Math.round( + performance.now() - activatingTimestamp - parseFloat(upTime) * 1000 + ); + sendInfo("", { + name: "client-initialize-time", + message: interval.toString() + }); + } + } } diff --git a/src/extension.ts b/src/extension.ts index ff2a2822..ddcbb1e0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -26,8 +26,10 @@ import { showWelcomeWebview, WelcomeViewSerializer } from "./welcome"; let cleanJavaWorkspaceIndicator: string; let activatedTimestamp: number; +export let activatingTimestamp: number; export async function activate(context: vscode.ExtensionContext) { + activatingTimestamp = performance.now(); syncState(context); initializeTelemetry(context); // initialize exp service ahead of activation operation to make sure exp context properties are set.