Skip to content

Raw Session Telemetry #11355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/client/datascience/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,15 @@ export enum Telemetry {
IPyWidgetPromptToUseCDNSelection = 'DS_INTERNAL.IPYWIDGET_PROMPT_TO_USE_CDN_SELECTION',
IPyWidgetOverhead = 'DS_INTERNAL.IPYWIDGET_OVERHEAD',
IPyWidgetRenderFailure = 'DS_INTERNAL.IPYWIDGET_RENDER_FAILURE',
IPyWidgetUnhandledMessage = 'DS_INTERNAL.IPYWIDGET_UNHANDLED_MESSAGE'
IPyWidgetUnhandledMessage = 'DS_INTERNAL.IPYWIDGET_UNHANDLED_MESSAGE',
RawKernelCreatingNotebook = 'DS_INTERNAL.RAWKERNEL_CREATING_NOTEBOOK',
JupyterCreatingNotebook = 'DS_INTERNAL.JUPYTER_CREATING_NOTEBOOK',
RawKernelSessionConnect = 'DS_INTERNAL.RAWKERNEL_SESSION_CONNECT',
RawKernelStartRawSession = 'DS_INTERNAL.RAWKERNEL_START_RAW_SESSION',
RawKernelSessionStartSuccess = 'DS_INTERNAL.RAWKERNEL_SESSION_START_SUCCESS',
RawKernelSessionStartUserCancel = 'DS_INTERNAL.RAWKERNEL_SESSION_START_USER_CANCEL',
RawKernelSessionStartTimeout = 'DS_INTERNAL.RAWKERNEL_SESSION_START_TIMEOUT',
RawKernelSessionStartException = 'DS_INTERNAL.RAWKERNEL_SESSION_START_EXCEPTION'
}

export enum NativeKeyboardCommandTelemetry {
Expand Down
3 changes: 3 additions & 0 deletions src/client/datascience/jupyter/jupyterServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { createDeferred, Deferred } from '../../common/utils/async';
import * as localize from '../../common/utils/localize';
import { noop } from '../../common/utils/misc';
import { IServiceContainer } from '../../ioc/types';
import { captureTelemetry } from '../../telemetry';
import { Telemetry } from '../constants';
import {
IJupyterConnection,
IJupyterSession,
Expand Down Expand Up @@ -94,6 +96,7 @@ export class JupyterServerBase implements INotebookServer {
this.savedSession = session;
}

@captureTelemetry(Telemetry.JupyterCreatingNotebook, undefined, true)
public createNotebook(
resource: Resource,
identity: Uri,
Expand Down
13 changes: 8 additions & 5 deletions src/client/datascience/raw-kernel/rawJupyterSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { Resource } from '../../common/types';
import { waitForPromise } from '../../common/utils/async';
import * as localize from '../../common/utils/localize';
import { IServiceContainer } from '../../ioc/types';
import { captureTelemetry, sendTelemetryEvent } from '../../telemetry';
import { BaseJupyterSession, ISession } from '../baseJupyterSession';
import { Telemetry } from '../constants';
import { KernelSelector } from '../jupyter/kernels/kernelSelector';
import { LiveKernelModel } from '../jupyter/kernels/types';
import { IKernelConnection, IKernelLauncher } from '../kernel-launcher/types';
Expand Down Expand Up @@ -40,6 +42,7 @@ export class RawJupyterSession extends BaseJupyterSession {
// RawKernels are good to go right away
}

@captureTelemetry(Telemetry.RawKernelSessionConnect, undefined, true)
public async connect(
resource: Resource,
timeout: number,
Expand All @@ -65,17 +68,21 @@ export class RawJupyterSession extends BaseJupyterSession {

// Only connect our session if we didn't cancel or timeout
if (newSession instanceof CancellationError) {
sendTelemetryEvent(Telemetry.RawKernelSessionStartUserCancel);
traceInfo('Starting of raw session cancelled by user');
throw newSession;
} else if (newSession === null) {
sendTelemetryEvent(Telemetry.RawKernelSessionStartTimeout);
traceError('Raw session failed to start in given timeout');
throw new Error(localize.DataScience.sessionDisposed());
} else {
sendTelemetryEvent(Telemetry.RawKernelSessionStartSuccess);
traceInfo('Raw session started and connected');
this.session = newSession;
this.kernelSpec = newSession.process?.kernelSpec;
}
} catch (error) {
sendTelemetryEvent(Telemetry.RawKernelSessionStartException);
traceError(`Failed to connect raw kernel session: ${error}`);
this.connected = false;
throw error;
Expand Down Expand Up @@ -121,14 +128,10 @@ export class RawJupyterSession extends BaseJupyterSession {
});
}

@captureTelemetry(Telemetry.RawKernelStartRawSession, undefined, true)
private async startRawSession(resource: Resource, kernelName?: string | IJupyterKernelSpec): Promise<ISession> {
const process = await this.kernelLauncher.launch(resource, kernelName);

if (!process.connection) {
traceError('KernelProcess launched without connection info');
throw new Error(localize.DataScience.sessionDisposed());
}

// Wait for the process to actually be ready to connect to
await process.ready;

Expand Down
3 changes: 3 additions & 0 deletions src/client/datascience/raw-kernel/rawNotebookProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { traceInfo } from '../../common/logger';
import { IAsyncDisposableRegistry, Resource } from '../../common/types';
import * as localize from '../../common/utils/localize';
import { noop } from '../../common/utils/misc';
import { captureTelemetry } from '../../telemetry';
import { Telemetry } from '../constants';
import { INotebook, IRawConnection, IRawNotebookProvider } from '../types';

class RawConnection implements IRawConnection {
Expand Down Expand Up @@ -45,6 +47,7 @@ export class RawNotebookProviderBase implements IRawNotebookProvider {
return Promise.resolve(this.rawConnection);
}

@captureTelemetry(Telemetry.RawKernelCreatingNotebook, undefined, true)
public async createNotebook(
identity: Uri,
resource: Resource,
Expand Down
14 changes: 14 additions & 0 deletions src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2035,4 +2035,18 @@ export interface IEventNamePropertyMapping {
[Telemetry.IPyWidgetUnhandledMessage]: {
msg_type: string;
};

// Telemetry send when we create a notebook for a raw kernel or jupyter
[Telemetry.RawKernelCreatingNotebook]: never | undefined;
[Telemetry.JupyterCreatingNotebook]: never | undefined;

// Raw kernel timing events
[Telemetry.RawKernelSessionConnect]: never | undefined;
[Telemetry.RawKernelStartRawSession]: never | undefined;

// Raw kernel single events
[Telemetry.RawKernelSessionStartSuccess]: never | undefined;
[Telemetry.RawKernelSessionStartException]: never | undefined;
[Telemetry.RawKernelSessionStartTimeout]: never | undefined;
[Telemetry.RawKernelSessionStartUserCancel]: never | undefined;
}