Skip to content

Commit 4d51ad6

Browse files
committed
Log event name when heartbeat failed and 🆙
1 parent b00e7ff commit 4d51ad6

File tree

2 files changed

+50
-47
lines changed

2 files changed

+50
-47
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Gitpod",
44
"description": "Gitpod Support",
55
"publisher": "gitpod",
6-
"version": "0.0.71",
6+
"version": "0.0.72",
77
"license": "MIT",
88
"icon": "resources/gitpod.png",
99
"repository": {
@@ -180,4 +180,4 @@
180180
"uuid": "8.1.0",
181181
"yazl": "^2.5.1"
182182
}
183-
}
183+
}

src/heartbeat.ts

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export class HeartbeatManager extends Disposable {
1717
static HEARTBEAT_INTERVAL = 30000;
1818

1919
private lastActivity = new Date().getTime();
20+
private lastActivityEvent: string = 'init';
2021
private isWorkspaceRunning = true;
2122
private heartBeatHandle: NodeJS.Timer | undefined;
2223

@@ -31,50 +32,49 @@ export class HeartbeatManager extends Disposable {
3132
private readonly telemetry: TelemetryReporter
3233
) {
3334
super();
34-
35-
this._register(vscode.window.onDidChangeActiveTextEditor(this.updateLastActivitiy, this));
36-
this._register(vscode.window.onDidChangeVisibleTextEditors(this.updateLastActivitiy, this));
37-
this._register(vscode.window.onDidChangeTextEditorSelection(this.updateLastActivitiy, this));
38-
this._register(vscode.window.onDidChangeTextEditorVisibleRanges(this.updateLastActivitiy, this));
39-
this._register(vscode.window.onDidChangeTextEditorOptions(this.updateLastActivitiy, this));
40-
this._register(vscode.window.onDidChangeTextEditorViewColumn(this.updateLastActivitiy, this));
41-
this._register(vscode.window.onDidChangeActiveTerminal(this.updateLastActivitiy, this));
42-
this._register(vscode.window.onDidOpenTerminal(this.updateLastActivitiy, this));
43-
this._register(vscode.window.onDidCloseTerminal(this.updateLastActivitiy, this));
44-
this._register(vscode.window.onDidChangeTerminalState(this.updateLastActivitiy, this));
45-
this._register(vscode.window.onDidChangeWindowState(this.updateLastActivitiy, this));
46-
this._register(vscode.window.onDidChangeActiveColorTheme(this.updateLastActivitiy, this));
47-
this._register(vscode.authentication.onDidChangeSessions(this.updateLastActivitiy, this));
48-
this._register(vscode.debug.onDidChangeActiveDebugSession(this.updateLastActivitiy, this));
49-
this._register(vscode.debug.onDidStartDebugSession(this.updateLastActivitiy, this));
50-
this._register(vscode.debug.onDidReceiveDebugSessionCustomEvent(this.updateLastActivitiy, this));
51-
this._register(vscode.debug.onDidTerminateDebugSession(this.updateLastActivitiy, this));
52-
this._register(vscode.debug.onDidChangeBreakpoints(this.updateLastActivitiy, this));
53-
this._register(vscode.extensions.onDidChange(this.updateLastActivitiy, this));
54-
this._register(vscode.languages.onDidChangeDiagnostics(this.updateLastActivitiy, this));
55-
this._register(vscode.tasks.onDidStartTask(this.updateLastActivitiy, this));
56-
this._register(vscode.tasks.onDidStartTaskProcess(this.updateLastActivitiy, this));
57-
this._register(vscode.tasks.onDidEndTask(this.updateLastActivitiy, this));
58-
this._register(vscode.tasks.onDidEndTaskProcess(this.updateLastActivitiy, this));
59-
this._register(vscode.workspace.onDidChangeWorkspaceFolders(this.updateLastActivitiy, this));
60-
this._register(vscode.workspace.onDidOpenTextDocument(this.updateLastActivitiy, this));
61-
this._register(vscode.workspace.onDidCloseTextDocument(this.updateLastActivitiy, this));
62-
this._register(vscode.workspace.onDidChangeTextDocument(this.updateLastActivitiy, this));
63-
this._register(vscode.workspace.onDidSaveTextDocument(this.updateLastActivitiy, this));
64-
this._register(vscode.workspace.onDidChangeNotebookDocument(this.updateLastActivitiy, this));
65-
this._register(vscode.workspace.onDidSaveNotebookDocument(this.updateLastActivitiy, this));
66-
this._register(vscode.workspace.onDidOpenNotebookDocument(this.updateLastActivitiy, this));
67-
this._register(vscode.workspace.onDidCloseNotebookDocument(this.updateLastActivitiy, this));
68-
this._register(vscode.workspace.onWillCreateFiles(this.updateLastActivitiy, this));
69-
this._register(vscode.workspace.onDidCreateFiles(this.updateLastActivitiy, this));
70-
this._register(vscode.workspace.onWillDeleteFiles(this.updateLastActivitiy, this));
71-
this._register(vscode.workspace.onDidDeleteFiles(this.updateLastActivitiy, this));
72-
this._register(vscode.workspace.onWillRenameFiles(this.updateLastActivitiy, this));
73-
this._register(vscode.workspace.onDidRenameFiles(this.updateLastActivitiy, this));
74-
this._register(vscode.workspace.onDidChangeConfiguration(this.updateLastActivitiy, this));
35+
this._register(vscode.window.onDidChangeActiveTextEditor(this.updateLastActivitiy('onDidChangeActiveTextEditor'), this));
36+
this._register(vscode.window.onDidChangeVisibleTextEditors(this.updateLastActivitiy('onDidChangeVisibleTextEditors'), this));
37+
this._register(vscode.window.onDidChangeTextEditorSelection(this.updateLastActivitiy('onDidChangeTextEditorSelection'), this));
38+
this._register(vscode.window.onDidChangeTextEditorVisibleRanges(this.updateLastActivitiy('onDidChangeTextEditorVisibleRanges'), this));
39+
this._register(vscode.window.onDidChangeTextEditorOptions(this.updateLastActivitiy('onDidChangeTextEditorOptions'), this));
40+
this._register(vscode.window.onDidChangeTextEditorViewColumn(this.updateLastActivitiy('onDidChangeTextEditorViewColumn'), this));
41+
this._register(vscode.window.onDidChangeActiveTerminal(this.updateLastActivitiy('onDidChangeActiveTerminal'), this));
42+
this._register(vscode.window.onDidOpenTerminal(this.updateLastActivitiy('onDidOpenTerminal'), this));
43+
this._register(vscode.window.onDidCloseTerminal(this.updateLastActivitiy('onDidCloseTerminal'), this));
44+
this._register(vscode.window.onDidChangeTerminalState(this.updateLastActivitiy('onDidChangeTerminalState'), this));
45+
this._register(vscode.window.onDidChangeWindowState(this.updateLastActivitiy('onDidChangeWindowState'), this));
46+
this._register(vscode.window.onDidChangeActiveColorTheme(this.updateLastActivitiy('onDidChangeActiveColorTheme'), this));
47+
this._register(vscode.authentication.onDidChangeSessions(this.updateLastActivitiy('onDidChangeSessions'), this));
48+
this._register(vscode.debug.onDidChangeActiveDebugSession(this.updateLastActivitiy('onDidChangeActiveDebugSession'), this));
49+
this._register(vscode.debug.onDidStartDebugSession(this.updateLastActivitiy('onDidStartDebugSession'), this));
50+
this._register(vscode.debug.onDidReceiveDebugSessionCustomEvent(this.updateLastActivitiy('onDidReceiveDebugSessionCustomEvent'), this));
51+
this._register(vscode.debug.onDidTerminateDebugSession(this.updateLastActivitiy('onDidTerminateDebugSession'), this));
52+
this._register(vscode.debug.onDidChangeBreakpoints(this.updateLastActivitiy('onDidChangeBreakpoints'), this));
53+
this._register(vscode.extensions.onDidChange(this.updateLastActivitiy('onDidChange'), this));
54+
this._register(vscode.languages.onDidChangeDiagnostics(this.updateLastActivitiy('onDidChangeDiagnostics'), this));
55+
this._register(vscode.tasks.onDidStartTask(this.updateLastActivitiy('onDidStartTask'), this));
56+
this._register(vscode.tasks.onDidStartTaskProcess(this.updateLastActivitiy('onDidStartTaskProcess'), this));
57+
this._register(vscode.tasks.onDidEndTask(this.updateLastActivitiy('onDidEndTask'), this));
58+
this._register(vscode.tasks.onDidEndTaskProcess(this.updateLastActivitiy('onDidEndTaskProcess'), this));
59+
this._register(vscode.workspace.onDidChangeWorkspaceFolders(this.updateLastActivitiy('onDidChangeWorkspaceFolders'), this));
60+
this._register(vscode.workspace.onDidOpenTextDocument(this.updateLastActivitiy('onDidOpenTextDocument'), this));
61+
this._register(vscode.workspace.onDidCloseTextDocument(this.updateLastActivitiy('onDidCloseTextDocument'), this));
62+
this._register(vscode.workspace.onDidChangeTextDocument(this.updateLastActivitiy('onDidChangeTextDocument'), this));
63+
this._register(vscode.workspace.onDidSaveTextDocument(this.updateLastActivitiy('onDidSaveTextDocument'), this));
64+
this._register(vscode.workspace.onDidChangeNotebookDocument(this.updateLastActivitiy('onDidChangeNotebookDocument'), this));
65+
this._register(vscode.workspace.onDidSaveNotebookDocument(this.updateLastActivitiy('onDidSaveNotebookDocument'), this));
66+
this._register(vscode.workspace.onDidOpenNotebookDocument(this.updateLastActivitiy('onDidOpenNotebookDocument'), this));
67+
this._register(vscode.workspace.onDidCloseNotebookDocument(this.updateLastActivitiy('onDidCloseNotebookDocument'), this));
68+
this._register(vscode.workspace.onWillCreateFiles(this.updateLastActivitiy('onWillCreateFiles'), this));
69+
this._register(vscode.workspace.onDidCreateFiles(this.updateLastActivitiy('onDidCreateFiles'), this));
70+
this._register(vscode.workspace.onWillDeleteFiles(this.updateLastActivitiy('onWillDeleteFiles'), this));
71+
this._register(vscode.workspace.onDidDeleteFiles(this.updateLastActivitiy('onDidDeleteFiles'), this));
72+
this._register(vscode.workspace.onWillRenameFiles(this.updateLastActivitiy('onWillRenameFiles'), this));
73+
this._register(vscode.workspace.onDidRenameFiles(this.updateLastActivitiy('onDidRenameFiles'), this));
74+
this._register(vscode.workspace.onDidChangeConfiguration(this.updateLastActivitiy('onDidChangeConfiguration'), this));
7575
this._register(vscode.languages.registerHoverProvider('*', {
7676
provideHover: () => {
77-
this.updateLastActivitiy();
77+
this.updateLastActivitiy('registerHoverProvider')();
7878
return null;
7979
}
8080
}));
@@ -95,8 +95,11 @@ export class HeartbeatManager extends Disposable {
9595
}, HeartbeatManager.HEARTBEAT_INTERVAL);
9696
}
9797

98-
private updateLastActivitiy() {
99-
this.lastActivity = new Date().getTime();
98+
private updateLastActivitiy(event: string) {
99+
return () => {
100+
this.lastActivity = new Date().getTime();
101+
this.lastActivityEvent = event;
102+
};
100103
}
101104

102105
private async sendHeartBeat(wasClosed?: true) {
@@ -123,7 +126,7 @@ export class HeartbeatManager extends Disposable {
123126
}
124127
}, this.logger);
125128
} catch (err) {
126-
this.logger.error(`Failed to send ${suffix}:`, err);
129+
this.logger.error(`Failed to send ${suffix} with event ${this.lastActivityEvent}:`, err);
127130
}
128131
}
129132

0 commit comments

Comments
 (0)