@@ -23,13 +23,15 @@ import { initialize as initUtils } from "./utils";
23
23
import { KEY_SHOW_WHEN_USING_JAVA } from "./utils/globalState" ;
24
24
import { scheduleAction } from "./utils/scheduler" ;
25
25
import { showWelcomeWebview , WelcomeViewSerializer } from "./welcome" ;
26
+ import { promisify } from "util" ;
26
27
27
28
let cleanJavaWorkspaceIndicator : string ;
28
- let activatedTimestamp : number ;
29
29
export let activatingTimestamp : number ;
30
30
31
31
export async function activate ( context : vscode . ExtensionContext ) {
32
32
activatingTimestamp = performance . now ( ) ;
33
+ // monitor the startup time at very beginning in case we miss the activation of java extension.
34
+ recordStartupTime ( ) ;
33
35
syncState ( context ) ;
34
36
initializeTelemetry ( context ) ;
35
37
// initialize exp service ahead of activation operation to make sure exp context properties are set.
@@ -45,7 +47,6 @@ async function initializeExtension(_operationId: string, context: vscode.Extensi
45
47
initRecommendations ( context ) ;
46
48
initDaemon ( context ) ;
47
49
48
- activatedTimestamp = performance . now ( ) ;
49
50
if ( context . storageUri ) {
50
51
const javaWorkspaceStoragePath = path . join ( context . storageUri . fsPath , ".." , "redhat.java" ) ;
51
52
cleanJavaWorkspaceIndicator = path . join ( javaWorkspaceStoragePath , "jdt_ws" , ".cleanWorkspace" ) ;
@@ -105,11 +106,36 @@ export async function deactivate() {
105
106
const now = performance . now ( ) ;
106
107
const data = {
107
108
name : "sessionStatus" ,
108
- time : Math . round ( now - activatedTimestamp )
109
+ time : Math . round ( now - activatingTimestamp )
109
110
}
110
111
if ( cleanJavaWorkspaceIndicator && fs . existsSync ( cleanJavaWorkspaceIndicator ) ) {
111
112
data . name = "cleanJavaLSWorkspace" ;
112
113
}
113
114
sendInfo ( "" , data ) ;
114
115
await disposeTelemetryWrapper ( ) ;
115
116
}
117
+
118
+ async function recordStartupTime ( ) {
119
+ const javaExt = vscode . extensions . getExtension ( "redhat.java" ) ;
120
+ // only count the e2e time when java extension is not activated at the moment.
121
+ // if it's already activated, we are not clear if it is activated with pack at
122
+ // the same moment.
123
+ if ( javaExt && ! javaExt . isActive ) {
124
+ const delay = promisify ( setTimeout ) ;
125
+ const timeout = 1 * 60 * 1000 ; // wait 1 min at most
126
+ let count = 0 ;
127
+ while ( ! javaExt . isActive && count < timeout ) {
128
+ await delay ( 1000 ) ;
129
+ count += 1000 ;
130
+ }
131
+ if ( javaExt . isActive && javaExt . exports ?. serverReady ) {
132
+ javaExt . exports . serverReady ( ) . then ( ( ) => {
133
+ const message = Math . round ( performance . now ( ) - activatingTimestamp ) . toString ( ) ;
134
+ sendInfo ( "" , {
135
+ name : "e2e-startup-time" ,
136
+ message,
137
+ } ) ;
138
+ } ) ;
139
+ }
140
+ }
141
+ }
0 commit comments