From 9a60a6f3bcaf185e6caaa09d996ef27bd6044919 Mon Sep 17 00:00:00 2001 From: David Barbet Date: Tue, 5 Nov 2024 17:26:25 -0800 Subject: [PATCH] Improve activation telemetry to track down when dropoffs occur --- l10n/bundle.l10n.json | 1 + src/lsptoolshost/roslynLanguageServer.ts | 9 ++++++++- src/main.ts | 3 ++- src/shared/telemetryEventNames.ts | 19 +++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/shared/telemetryEventNames.ts diff --git a/l10n/bundle.l10n.json b/l10n/bundle.l10n.json index e504aad2b7..78c2fbd134 100644 --- a/l10n/bundle.l10n.json +++ b/l10n/bundle.l10n.json @@ -61,6 +61,7 @@ "Could not locate .NET Core project in '{0}'. Assets were not generated.": "Could not locate .NET Core project in '{0}'. Assets were not generated.", "Unable to generate assets to build and debug. {0}.": "Unable to generate assets to build and debug. {0}.", "Cannot load Razor language server because the directory was not found: '{0}'": "Cannot load Razor language server because the directory was not found: '{0}'", + "Razor Log": "Razor Log", "Could not find '{0}' in or above '{1}'.": "Could not find '{0}' in or above '{1}'.", "Invalid razor.server.trace setting. Defaulting to '{0}'": "Invalid razor.server.trace setting. Defaulting to '{0}'", "Could not find Razor Language Server executable '{0}' within directory": "Could not find Razor Language Server executable '{0}' within directory", diff --git a/src/lsptoolshost/roslynLanguageServer.ts b/src/lsptoolshost/roslynLanguageServer.ts index 1ca6ea1d66..58f08d5c56 100644 --- a/src/lsptoolshost/roslynLanguageServer.ts +++ b/src/lsptoolshost/roslynLanguageServer.ts @@ -76,6 +76,7 @@ import { } from '../shared/observers/utils/showMessage'; import { registerSourceGeneratedFilesContentProvider } from './sourceGeneratedFilesContentProvider'; import { registerMiscellaneousFileNotifier } from './miscellaneousFileNotifier'; +import { TelemetryEventNames } from '../shared/telemetryEventNames'; let _channel: vscode.LogOutputChannel; let _traceChannel: vscode.OutputChannel; @@ -574,12 +575,13 @@ export class RoslynLanguageServer { telemetryReporter: TelemetryReporter, additionalExtensionPaths: string[] ): Promise { + telemetryReporter.sendTelemetryEvent(TelemetryEventNames.ClientServerStart); const serverPath = getServerPath(platformInfo); const dotnetInfo = await hostExecutableResolver.getHostExecutableInfo(); const dotnetExecutablePath = dotnetInfo.path; - _channel.info('Dotnet path: ' + dotnetExecutablePath); + telemetryReporter.sendTelemetryEvent(TelemetryEventNames.AcquiredRuntime); let args: string[] = []; @@ -684,6 +686,8 @@ export class RoslynLanguageServer { childProcess = cp.spawn(serverPath, args, cpOptions); } + telemetryReporter.sendTelemetryEvent(TelemetryEventNames.LaunchedServer); + // Record the stdout and stderr streams from the server process. childProcess.stdout.on('data', (data: { toString: (arg0: any) => any }) => { const result: string = isString(data) ? data : data.toString(RoslynLanguageServer.encoding); @@ -756,6 +760,8 @@ export class RoslynLanguageServer { throw new Error('Timeout. Client cound not connect to server via named pipe'); } + telemetryReporter.sendTelemetryEvent(TelemetryEventNames.ClientConnected); + return { reader: new SocketMessageReader(socket, RoslynLanguageServer.encoding), writer: new SocketMessageWriter(socket, RoslynLanguageServer.encoding), @@ -1071,6 +1077,7 @@ export async function activateRoslynLanguageServer( // Create a separate channel for outputting trace logs - these are incredibly verbose and make other logs very difficult to see. // The trace channel verbosity is controlled by the _channel verbosity. _traceChannel = vscode.window.createOutputChannel(vscode.l10n.t('C# LSP Trace Logs')); + reporter.sendTelemetryEvent(TelemetryEventNames.ClientInitialize); const hostExecutableResolver = new DotnetRuntimeExtensionResolver( platformInfo, diff --git a/src/main.ts b/src/main.ts index e928493e84..81ab8d03f9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -41,6 +41,7 @@ import { debugSessionTracker } from './coreclrDebug/provisionalDebugSessionTrack import { getComponentFolder } from './lsptoolshost/builtInComponents'; import { activateOmniSharpLanguageServer, ActivationResult } from './omnisharp/omnisharpLanguageServer'; import { ActionOption, showErrorMessage } from './shared/observers/utils/showMessage'; +import { TelemetryEventNames } from './shared/telemetryEventNames'; export async function activate( context: vscode.ExtensionContext @@ -218,7 +219,7 @@ export async function activate( const activationProperties: { [key: string]: string } = { serverKind: useOmnisharpServer ? 'OmniSharp' : 'Roslyn', }; - reporter.sendTelemetryEvent('CSharpActivated', activationProperties); + reporter.sendTelemetryEvent(TelemetryEventNames.CSharpActivated, activationProperties); if (!useOmnisharpServer) { debugSessionTracker.initializeDebugSessionHandlers(context); diff --git a/src/shared/telemetryEventNames.ts b/src/shared/telemetryEventNames.ts new file mode 100644 index 0000000000..88b065b605 --- /dev/null +++ b/src/shared/telemetryEventNames.ts @@ -0,0 +1,19 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +/** + * Defines all telemetry event names to ensure we do not have overlapping events. + */ +export enum TelemetryEventNames { + // Common extension events + CSharpActivated = 'CSharpActivated', + + // Events related to the roslyn language server. + ClientInitialize = 'roslyn/clientInitialize', + ClientServerStart = 'roslyn/clientServerInitialize', + AcquiredRuntime = 'roslyn/acquiredRuntime', + LaunchedServer = 'roslyn/launchedServer', + ClientConnected = 'roslyn/clientConnected', +}