Skip to content

Commit

Permalink
Send the client initialize time (#1199)
Browse files Browse the repository at this point in the history
Signed-off-by: Sheng Chen <[email protected]>
  • Loading branch information
jdneo authored May 23, 2023
1 parent cb8b206 commit 831aacd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/daemon/processWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()
});
}
}
}


Expand Down
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 831aacd

Please sign in to comment.