Skip to content

Commit

Permalink
Merge pull request #7739 from dibarbet/activation_telemetry
Browse files Browse the repository at this point in the history
Improve activation telemetry to track down when dropoffs occur
  • Loading branch information
dibarbet authored Nov 6, 2024
2 parents b545060 + ae7c81c commit 2a8aac5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
10 changes: 9 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 @@ -1072,6 +1078,8 @@ export async function activateRoslynLanguageServer(
// The trace channel verbosity is controlled by the _channel verbosity.
_traceChannel = vscode.window.createOutputChannel('C# LSP Trace Logs');

reporter.sendTelemetryEvent(TelemetryEventNames.ClientInitialize);

const hostExecutableResolver = new DotnetRuntimeExtensionResolver(
platformInfo,
getServerPath,
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 2a8aac5

Please sign in to comment.