Skip to content

Commit

Permalink
Improve activation telemetry to track down when dropoffs occur
Browse files Browse the repository at this point in the history
  • Loading branch information
dibarbet committed Nov 6, 2024
1 parent c51b3c7 commit 9a60a6f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 8 additions & 1 deletion src/lsptoolshost/roslynLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -574,12 +575,13 @@ export class RoslynLanguageServer {
telemetryReporter: TelemetryReporter,
additionalExtensionPaths: string[]
): Promise<MessageTransports> {
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[] = [];

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
19 changes: 19 additions & 0 deletions src/shared/telemetryEventNames.ts
Original file line number Diff line number Diff line change
@@ -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',
}

0 comments on commit 9a60a6f

Please sign in to comment.