Skip to content

Commit

Permalink
Restart reason telemetry event for pylance (#20821)
Browse files Browse the repository at this point in the history
Closes #19626
  • Loading branch information
karthiknadig authored Mar 9, 2023
1 parent 8a80ebe commit b897300
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/client/activation/node/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IDisposable, IExtensions, Resource } from '../../common/types';
import { debounceSync } from '../../common/utils/decorators';
import { IServiceContainer } from '../../ioc/types';
import { PythonEnvironment } from '../../pythonEnvironments/info';
import { captureTelemetry } from '../../telemetry';
import { captureTelemetry, sendTelemetryEvent } from '../../telemetry';
import { EventName } from '../../telemetry/constants';
import { Commands } from '../commands';
import { NodeLanguageClientMiddleware } from './languageClientMiddleware';
Expand Down Expand Up @@ -44,6 +44,7 @@ export class NodeLanguageServerManager implements ILanguageServerManager {
NodeLanguageServerManager.commandDispose.dispose();
}
NodeLanguageServerManager.commandDispose = commandManager.registerCommand(Commands.RestartLS, () => {
sendTelemetryEvent(EventName.LANGUAGE_SERVER_RESTART, undefined, { reason: 'command' });
this.restartLanguageServer().ignoreErrors();
});
}
Expand Down Expand Up @@ -94,6 +95,7 @@ export class NodeLanguageServerManager implements ILanguageServerManager {

@debounceSync(1000)
protected restartLanguageServerDebounced(): void {
sendTelemetryEvent(EventName.LANGUAGE_SERVER_RESTART, undefined, { reason: 'settings' });
this.restartLanguageServer().ignoreErrors();
}

Expand Down
3 changes: 3 additions & 0 deletions src/client/languageServer/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { NoneLSExtensionManager } from './noneLSExtensionManager';
import { PylanceLSExtensionManager } from './pylanceLSExtensionManager';
import { ILanguageServerExtensionManager, ILanguageServerWatcher } from './types';
import { LspNotebooksExperiment } from '../activation/node/lspNotebooksExperiment';
import { sendTelemetryEvent } from '../telemetry';
import { EventName } from '../telemetry/constants';

@injectable()
/**
Expand Down Expand Up @@ -184,6 +186,7 @@ export class LanguageServerWatcher implements IExtensionActivationService, ILang

public async restartLanguageServers(): Promise<void> {
this.workspaceLanguageServers.forEach(async (_, resourceString) => {
sendTelemetryEvent(EventName.LANGUAGE_SERVER_RESTART, undefined, { reason: 'notebooksExperiment' });
const resource = Uri.parse(resourceString);
await this.stopLanguageServer(resource);
await this.startLanguageServer(this.languageServerType, resource);
Expand Down
1 change: 1 addition & 0 deletions src/client/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export enum EventName {
LANGUAGE_SERVER_READY = 'LANGUAGE_SERVER.READY',
LANGUAGE_SERVER_TELEMETRY = 'LANGUAGE_SERVER.EVENT',
LANGUAGE_SERVER_REQUEST = 'LANGUAGE_SERVER.REQUEST',
LANGUAGE_SERVER_RESTART = 'LANGUAGE_SERVER.RESTART',

TERMINAL_CREATE = 'TERMINAL.CREATE',
ACTIVATE_ENV_IN_CURRENT_TERMINAL = 'ACTIVATE_ENV_IN_CURRENT_TERMINAL',
Expand Down
11 changes: 11 additions & 0 deletions src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,17 @@ export interface IEventNamePropertyMapping {
}
*/
[EventName.LANGUAGE_SERVER_REQUEST]: unknown;
/**
* Telemetry send when Language Server is restarted.
*/
/* __GDPR__
"language_server_restart" : {
"reason" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "karthiknadig" }
}
*/
[EventName.LANGUAGE_SERVER_RESTART]: {
reason: 'command' | 'settings' | 'notebooksExperiment';
};
/**
* Telemetry event sent when Jedi Language Server is started for workspace (workspace folder in case of multi-root)
*/
Expand Down

0 comments on commit b897300

Please sign in to comment.