From 511d857b49ecca1029847e709e4581d12d5307c5 Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Tue, 16 Feb 2021 16:46:54 -0800 Subject: [PATCH] Update start-up telemetry for Jedi LSP (#15419) --- src/client/activation/activationService.ts | 2 +- .../activation/jedi/languageServerProxy.ts | 28 +++++-------------- src/client/activation/jedi/manager.ts | 2 +- src/client/telemetry/constants.ts | 5 ++++ src/client/telemetry/index.ts | 26 +++++++++++++++++ 5 files changed, 40 insertions(+), 23 deletions(-) diff --git a/src/client/activation/activationService.ts b/src/client/activation/activationService.ts index 2f939da226c5..6e9735fb0135 100644 --- a/src/client/activation/activationService.ts +++ b/src/client/activation/activationService.ts @@ -279,7 +279,7 @@ export class LanguageServerExtensionActivationService outputLine = LanguageService.startingNone(); break; default: - throw new Error('Unknown langauge server type in activator.'); + throw new Error('Unknown language server type in activator.'); } this.output.appendLine(outputLine); } diff --git a/src/client/activation/jedi/languageServerProxy.ts b/src/client/activation/jedi/languageServerProxy.ts index f086225481f4..33e6e31225b6 100644 --- a/src/client/activation/jedi/languageServerProxy.ts +++ b/src/client/activation/jedi/languageServerProxy.ts @@ -13,13 +13,13 @@ import { import { DeprecatePythonPath } from '../../common/experiments/groups'; import { traceDecorators, traceError } from '../../common/logger'; -import { IConfigurationService, IExperimentsManager, IInterpreterPathService, Resource } from '../../common/types'; +import { IExperimentsManager, IInterpreterPathService, Resource } from '../../common/types'; import { createDeferred, Deferred, sleep } from '../../common/utils/async'; import { swallowExceptions } from '../../common/utils/decorators'; import { noop } from '../../common/utils/misc'; import { LanguageServerSymbolProvider } from '../../providers/symbolProvider'; import { PythonEnvironment } from '../../pythonEnvironments/info'; -import { captureTelemetry, sendTelemetryEvent } from '../../telemetry'; +import { captureTelemetry } from '../../telemetry'; import { EventName } from '../../telemetry/constants'; import { ITestManagementService } from '../../testing/types'; import { FileBasedCancellationStrategy } from '../common/cancellationUtils'; @@ -44,7 +44,6 @@ export class JediLanguageServerProxy implements ILanguageServerProxy { constructor( @inject(ILanguageClientFactory) private readonly factory: ILanguageClientFactory, @inject(ITestManagementService) private readonly testManager: ITestManagementService, - @inject(IConfigurationService) private readonly configurationService: IConfigurationService, @inject(IExperimentsManager) private readonly experiments: IExperimentsManager, @inject(IInterpreterPathService) private readonly interpreterPathService: IInterpreterPathService, ) { @@ -81,7 +80,7 @@ export class JediLanguageServerProxy implements ILanguageServerProxy { @traceDecorators.error('Failed to start language server') @captureTelemetry( - EventName.LANGUAGE_SERVER_ENABLED, + EventName.JEDI_LANGUAGE_SERVER_ENABLED, undefined, true, undefined, @@ -107,7 +106,7 @@ export class JediLanguageServerProxy implements ILanguageServerProxy { // late the server may have already sent a message (which leads to failures). Register // these on the state change to running to ensure they are ready soon enough. if (e.newState === State.Running) { - this.registerHandlers(resource); + this.registerHandlers(); } }); @@ -131,7 +130,7 @@ export class JediLanguageServerProxy implements ILanguageServerProxy { } @captureTelemetry( - EventName.LANGUAGE_SERVER_READY, + EventName.JEDI_LANGUAGE_SERVER_READY, undefined, true, undefined, @@ -155,7 +154,7 @@ export class JediLanguageServerProxy implements ILanguageServerProxy { await this.testManager.activate(new LanguageServerSymbolProvider(this.languageClient)); } - private registerHandlers(resource: Resource) { + private registerHandlers() { if (this.disposed) { // Check if it got disposed in the interim. return; @@ -167,7 +166,7 @@ export class JediLanguageServerProxy implements ILanguageServerProxy { if (this.experiments.inExperiment(DeprecatePythonPath.experiment)) { this.disposables.push( this.interpreterPathService.onDidChange(() => { - // Manually send didChangeConfiguration in order to get the server to requery + // Manually send didChangeConfiguration in order to get the server to re-query // the workspace configurations (to then pick up pythonPath set in the middleware). // This is needed as interpreter changes via the interpreter path service happen // outside of VS Code's settings (which would mean VS Code sends the config updates itself). @@ -177,18 +176,5 @@ export class JediLanguageServerProxy implements ILanguageServerProxy { }), ); } - - const settings = this.configurationService.getSettings(resource); - if (settings.downloadLanguageServer) { - this.languageClient!.onTelemetry((telemetryEvent) => { - const eventName = telemetryEvent.EventName || EventName.LANGUAGE_SERVER_TELEMETRY; - const formattedProperties = { - ...telemetryEvent.Properties, - // Replace all slashes in the method name so it doesn't get scrubbed by vscode-extension-telemetry. - method: telemetryEvent.Properties.method?.replace(/\//g, '.'), - }; - sendTelemetryEvent(eventName, telemetryEvent.Measurements, formattedProperties); - }); - } } } diff --git a/src/client/activation/jedi/manager.ts b/src/client/activation/jedi/manager.ts index 75efd14e38bd..1b00061b6f82 100644 --- a/src/client/activation/jedi/manager.ts +++ b/src/client/activation/jedi/manager.ts @@ -121,7 +121,7 @@ export class JediLanguageServerManager implements ILanguageServerManager { } @captureTelemetry( - EventName.LANGUAGE_SERVER_STARTUP, + EventName.JEDI_LANGUAGE_SERVER_STARTUP, undefined, true, undefined, diff --git a/src/client/telemetry/constants.ts b/src/client/telemetry/constants.ts index 0a5e8b893ac6..66ad81834b96 100644 --- a/src/client/telemetry/constants.ts +++ b/src/client/telemetry/constants.ts @@ -120,6 +120,11 @@ export enum EventName { HASHED_PACKAGE_PERF = 'HASHED_PACKAGE_PERF', JEDI_MEMORY = 'JEDI_MEMORY', + JEDI_LANGUAGE_SERVER_ENABLED = 'JEDI_LANGUAGE_SERVER.ENABLED', + JEDI_LANGUAGE_SERVER_STARTUP = 'JEDI_LANGUAGE_SERVER.STARTUP', + JEDI_LANGUAGE_SERVER_READY = 'JEDI_LANGUAGE_SERVER.READY', + JEDI_LANGUAGE_SERVER_TELEMETRY = 'JEDI_LANGUAGE_SERVER.EVENT', + JEDI_LANGUAGE_SERVER_REQUEST = 'JEDI_LANGUAGE_SERVER.REQUEST', TENSORBOARD_SESSION_LAUNCH = 'TENSORBOARD.SESSION_LAUNCH', TENSORBOARD_SESSION_DURATION = 'TENSORBOARD.SESSION_DURATION', diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index dd21ca1020e9..613128ce6223 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -1375,6 +1375,32 @@ export interface IEventNamePropertyMapping { */ userAction: string; }; + /** + * Telemetry event sent when Jedi Language Server is started for workspace (workspace folder in case of multi-root) + */ + [EventName.JEDI_LANGUAGE_SERVER_ENABLED]: { + lsVersion?: string; + }; + /** + * Telemetry event sent when Jedi Language Server server is ready to receive messages + */ + [EventName.JEDI_LANGUAGE_SERVER_READY]: { + lsVersion?: string; + }; + /** + * Telemetry event sent when starting Node.js server + */ + [EventName.JEDI_LANGUAGE_SERVER_STARTUP]: { + lsVersion?: string; + }; + /** + * Telemetry sent from Node.js server (details of telemetry sent can be provided by LS team) + */ + [EventName.JEDI_LANGUAGE_SERVER_TELEMETRY]: unknown; + /** + * Telemetry sent when the client makes a request to the Node.js server + */ + [EventName.JEDI_LANGUAGE_SERVER_REQUEST]: unknown; /** * Telemetry captured for enabling reload. */