Skip to content

Commit

Permalink
goLanguageServer: add extra information to automated error reports
Browse files Browse the repository at this point in the history
Keep track of the total number of times the language server has been
started and how many times it has been manually restarted by the user.
Total start count will account for the first start + any automated
restarts + any manual restarts.

Also, add the initialization to the automated error report.

Change-Id: If10b65a27d362dbf9a7c7815623670fbfdf6a360
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/287952
Trust: Rebecca Stambler <[email protected]>
Run-TryBot: Rebecca Stambler <[email protected]>
TryBot-Result: kokoro <[email protected]>
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
  • Loading branch information
stamblerre committed Jan 29, 2021
1 parent aac9542 commit 5d48c07
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/goLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ let languageServerStartInProgress = false;
let serverTraceChannel: vscode.OutputChannel;
let crashCount = 0;

// Some metrics for automated issue reports:
let manualRestartCount = 0;
let totalStartCount = 0;

// defaultLanguageProviders is the list of providers currently registered.
let defaultLanguageProviders: vscode.Disposable[] = [];

Expand Down Expand Up @@ -235,6 +239,8 @@ async function startLanguageServer(ctx: vscode.ExtensionContext, config: Languag
await suggestGoplsIssueReport(
`Looks like you're about to manually restart the language server.`,
errorKind.manualRestart);

manualRestartCount++;
restartLanguageServer();
});
ctx.subscriptions.push(restartCommand);
Expand All @@ -245,6 +251,7 @@ async function startLanguageServer(ctx: vscode.ExtensionContext, config: Languag
disposeDefaultProviders();

languageServerDisposable = languageClient.start();
totalStartCount++;
ctx.subscriptions.push(languageServerDisposable);
return true;
}
Expand Down Expand Up @@ -323,7 +330,7 @@ export async function buildLanguageClient(cfg: BuildLanguageClientOption): Promi
vscode.window.showErrorMessage(
`The language server is not able to serve any features. Initialization failed: ${error}. `
);
suggestGoplsIssueReport(`The gopls server failed to initialize.`, errorKind.initializationFailure);
suggestGoplsIssueReport(`The gopls server failed to initialize`, errorKind.initializationFailure, error);
return false;
},
errorHandler: {
Expand Down Expand Up @@ -1272,7 +1279,7 @@ enum errorKind {
}

// suggestGoplsIssueReport prompts users to file an issue with gopls.
async function suggestGoplsIssueReport(msg: string, reason: errorKind) {
async function suggestGoplsIssueReport(msg: string, reason: errorKind, initializationError?: WebRequest.ResponseError<InitializeError>) {
// Don't prompt users who manually restart to file issues until gopls/v1.0.
if (reason === errorKind.manualRestart) {
return;
Expand Down Expand Up @@ -1348,6 +1355,9 @@ gopls version: ${usersGoplsVersion}
gopls flags: ${settings}
extension version: ${extInfo.version}
environment: ${extInfo.appName}
initialization error: ${initializationError}
manual restart count: ${manualRestartCount}
total start count: ${totalStartCount}
ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.
Expand Down

0 comments on commit 5d48c07

Please sign in to comment.