Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

end-to-end performance tracking for code completion requests #3165

Merged
merged 4 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/standardLanguageClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { findRuntimes } from "jdk-utils";
import * as net from 'net';
import * as path from 'path';
import { CancellationToken, CodeActionKind, commands, ConfigurationTarget, DocumentSelector, EventEmitter, ExtensionContext, extensions, languages, Location, ProgressLocation, TextEditor, Uri, ViewColumn, window, workspace } from "vscode";
import { ConfigurationParams, ConfigurationRequest, LanguageClientOptions, Location as LSLocation, MessageType, Position as LSPosition, TextDocumentPositionParams, WorkspaceEdit } from "vscode-languageclient";
import { ConfigurationParams, ConfigurationRequest, LanguageClientOptions, Location as LSLocation, MessageType, Position as LSPosition, TextDocumentPositionParams, WorkspaceEdit, CompletionRequest } from "vscode-languageclient";
import { LanguageClient, StreamInfo } from "vscode-languageclient/node";
import { apiManager } from "./apiManager";
import * as buildPath from './buildpath';
import { javaRefactorKinds, RefactorDocumentProvider } from "./codeActionProvider";
import { Commands } from "./commands";
import { ClientStatus } from "./extension.api";
import { ClientStatus, TraceEvent } from "./extension.api";
import * as fileEventHandler from './fileEventHandler';
import { gradleCodeActionMetadata, GradleCodeActionProvider } from "./gradle/gradleCodeActionProvider";
import { awaitServerConnection, prepareExecutable, DEBUG } from "./javaServerStarter";
Expand Down Expand Up @@ -148,6 +148,7 @@ export class StandardLanguageClient {
// Disable the client-side snippet provider since LS is ready.
snippetCompletionProvider.dispose();
registerDocumentValidationListener(context, this.languageClient);
registerCodeCompletionTelemetryListener();
break;
case 'Started':
this.status = ClientStatus.started;
Expand Down Expand Up @@ -735,3 +736,21 @@ export async function applyWorkspaceEdit(workspaceEdit: WorkspaceEdit, languageC
return Promise.resolve(true);
}
}

export function registerCodeCompletionTelemetryListener() {
apiManager.getApiInstance().onDidRequestEnd((traceEvent: any) => {
rgrunber marked this conversation as resolved.
Show resolved Hide resolved
if (traceEvent.type === CompletionRequest.method) {
// Exclude the invalid completion requests.
if (!traceEvent.resultLength) {
return;
}
const event: TraceEvent = traceEvent as TraceEvent;
const props = {
duration: Math.round(event.duration * 100) / 100,
resultLength: event.resultLength || 0,
error: !!event.error,
};
return Telemetry.sendTelemetry(Telemetry.COMPLETION_EVENT, props);
}
});
}
1 change: 1 addition & 0 deletions src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ExtensionContext, workspace, WorkspaceConfiguration } from "vscode";
export namespace Telemetry {

export const STARTUP_EVT = "startup";
export const COMPLETION_EVENT = "textCompletion";
export const SERVER_INITIALIZED_EVT = "java.workspace.initialized";
let telemetryManager: TelemetryService = null;
let serverInitializedReceived = false;
Expand Down