mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 20:13:32 +01:00
Add telemetry for how long completions take in js/ts
We'd like to know the average time that it takes to return js/ts completions so that we can identify performance regressions. The time includes both the queuing time and the actual time spent executing the command against TS server
This commit is contained in:
@@ -7,7 +7,7 @@ import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import * as Proto from '../protocol';
|
||||
import * as PConst from '../protocol.const';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
import { ITypeScriptServiceClient, ServerResponse } from '../typescriptService';
|
||||
import API from '../utils/api';
|
||||
import { nulToken } from '../utils/cancellation';
|
||||
import { applyCodeAction } from '../utils/codeAction';
|
||||
@@ -15,10 +15,11 @@ import { Command, CommandManager } from '../utils/commandManager';
|
||||
import { ConfigurationDependentRegistration } from '../utils/dependentRegistration';
|
||||
import { memoize } from '../utils/memoize';
|
||||
import * as Previewer from '../utils/previewer';
|
||||
import { snippetForFunctionCall } from '../utils/snippetForFunctionCall';
|
||||
import TelemetryReporter from '../utils/telemetry';
|
||||
import * as typeConverters from '../utils/typeConverters';
|
||||
import TypingsStatus from '../utils/typingsStatus';
|
||||
import FileConfigurationManager from './fileConfigurationManager';
|
||||
import { snippetForFunctionCall } from '../utils/snippetForFunctionCall';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
@@ -333,6 +334,7 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
|
||||
private readonly typingsStatus: TypingsStatus,
|
||||
private readonly fileConfigurationManager: FileConfigurationManager,
|
||||
commandManager: CommandManager,
|
||||
private readonly telemetryReporter: TelemetryReporter,
|
||||
onCompletionAccepted: (item: vscode.CompletionItem) => void
|
||||
) {
|
||||
commandManager.register(new ApplyCompletionCodeActionCommand(this.client));
|
||||
@@ -385,7 +387,28 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
|
||||
let entries: ReadonlyArray<Proto.CompletionEntry>;
|
||||
let metadata: any | undefined;
|
||||
if (this.client.apiVersion.gte(API.v300)) {
|
||||
const response = await this.client.interruptGetErr(() => this.client.execute('completionInfo', args, token));
|
||||
const startTime = Date.now();
|
||||
let response: ServerResponse.Response<Proto.CompletionInfoResponse> | undefined;
|
||||
try {
|
||||
response = await this.client.interruptGetErr(() => this.client.execute('completionInfo', args, token));
|
||||
} finally {
|
||||
const duration: number = Date.now() - startTime;
|
||||
|
||||
/* __GDPR__
|
||||
"completions.execute" : {
|
||||
"duration" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" },
|
||||
"type" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" },
|
||||
"${include}": [
|
||||
"${TypeScriptCommonProperties}",
|
||||
]
|
||||
}
|
||||
*/
|
||||
this.telemetryReporter.logTelemetry('completions.execute', {
|
||||
duration: duration + '',
|
||||
type: response ? response.type : 'unknown'
|
||||
});
|
||||
}
|
||||
|
||||
if (response.type !== 'response' || !response.body) {
|
||||
return null;
|
||||
}
|
||||
@@ -677,10 +700,11 @@ export function register(
|
||||
typingsStatus: TypingsStatus,
|
||||
fileConfigurationManager: FileConfigurationManager,
|
||||
commandManager: CommandManager,
|
||||
telemetryReporter: TelemetryReporter,
|
||||
onCompletionAccepted: (item: vscode.CompletionItem) => void
|
||||
) {
|
||||
return new ConfigurationDependentRegistration(modeId, 'suggest.enabled', () =>
|
||||
vscode.languages.registerCompletionItemProvider(selector,
|
||||
new TypeScriptCompletionItemProvider(client, modeId, typingsStatus, fileConfigurationManager, commandManager, onCompletionAccepted),
|
||||
new TypeScriptCompletionItemProvider(client, modeId, typingsStatus, fileConfigurationManager, commandManager, telemetryReporter, onCompletionAccepted),
|
||||
...TypeScriptCompletionItemProvider.triggerCharacters));
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ export default class LanguageProvider extends Disposable {
|
||||
|
||||
const cachedResponse = new CachedResponse();
|
||||
|
||||
this._register((await import('./features/completions')).register(selector, this.description.id, this.client, this.typingsStatus, this.fileConfigurationManager, this.commandManager, this.onCompletionAccepted));
|
||||
this._register((await import('./features/completions')).register(selector, this.description.id, this.client, this.typingsStatus, this.fileConfigurationManager, this.commandManager, this.telemetryReporter, this.onCompletionAccepted));
|
||||
this._register((await import('./features/definitions')).register(selector, this.client));
|
||||
this._register((await import('./features/directiveCommentCompletions')).register(selector, this.client));
|
||||
this._register((await import('./features/documentHighlight')).register(selector, this.client));
|
||||
|
||||
Reference in New Issue
Block a user