Skip to content

Commit

Permalink
More telemetry related changes (#7635)
Browse files Browse the repository at this point in the history
* More telemetry related changes

* Misc
  • Loading branch information
DonJayamanne authored Sep 23, 2021
1 parent 94a80ee commit 5ea9ffc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ export class NotebookProvider implements INotebookProvider {
)
: this.jupyterNotebookProvider.createNotebook(options);

sendKernelTelemetryWhenDone(resource, Telemetry.NotebookStart, promise);
sendKernelTelemetryWhenDone(resource, Telemetry.NotebookStart, promise, undefined, {
disableUI: options.disableUI
});

this.cacheNotebookPromise(options.identity, promise);

Expand Down
13 changes: 11 additions & 2 deletions src/client/datascience/jupyter/kernels/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ import type { nbformat } from '@jupyterlab/coreutils';
import { concatMultilineString } from '../../../../datascience-ui/common';
import { CellHashProviderFactory } from '../../editor-integration/cellHashProviderFactory';
import { IPythonExecutionFactory } from '../../../common/process/types';
import { INotebookControllerManager } from '../../notebook/types';
import { getResourceType } from '../../common';

export class Kernel implements IKernel {
get connection(): INotebookProviderConnection | undefined {
Expand Down Expand Up @@ -125,7 +127,8 @@ export class Kernel implements IKernel {
outputTracker: CellOutputDisplayIdTracker,
private readonly workspaceService: IWorkspaceService,
private readonly cellHashProviderFactory: CellHashProviderFactory,
private readonly pythonExecutionFactory: IPythonExecutionFactory
private readonly pythonExecutionFactory: IPythonExecutionFactory,
notebookControllerManager: INotebookControllerManager
) {
this.kernelExecution = new KernelExecution(
this,
Expand All @@ -138,8 +141,14 @@ export class Kernel implements IKernel {
outputTracker,
cellHashProviderFactory
);
const isPreferredKernel =
getResourceType(resourceUri) === 'notebook'
? notebookControllerManager.getPreferredNotebookController(this.notebookDocument)?.controller ===
controller
: undefined;
trackKernelResourceInformation(resourceUri, {
kernelConnection: kernelConnectionMetadata
kernelConnection: kernelConnectionMetadata,
isPreferredKernel
});
}
private perceivedJupyterStartupTelemetryCaptured?: boolean;
Expand Down
8 changes: 6 additions & 2 deletions src/client/datascience/jupyter/kernels/kernelProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import {
IDisposableRegistry
} from '../../../common/types';
import { noop } from '../../../common/utils/misc';
import { IServiceContainer } from '../../../ioc/types';
import { CellHashProviderFactory } from '../../editor-integration/cellHashProviderFactory';
import { InteractiveWindowView } from '../../notebook/constants';
import { INotebookControllerManager } from '../../notebook/types';
import {
IDataScienceErrorHandler,
IJupyterServerUriStorage,
Expand Down Expand Up @@ -58,7 +60,8 @@ export class KernelProvider implements IKernelProvider {
@inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService,
@inject(CellHashProviderFactory) private cellHashProviderFactory: CellHashProviderFactory,
@inject(IVSCodeNotebook) private readonly notebook: IVSCodeNotebook,
@inject(IPythonExecutionFactory) private readonly pythonExecutionFactory: IPythonExecutionFactory
@inject(IPythonExecutionFactory) private readonly pythonExecutionFactory: IPythonExecutionFactory,
@inject(IServiceContainer) private readonly serviceContainer: IServiceContainer
) {
this.asyncDisposables.push(this);
}
Expand Down Expand Up @@ -107,7 +110,8 @@ export class KernelProvider implements IKernelProvider {
this.outputTracker,
this.workspaceService,
this.cellHashProviderFactory,
this.pythonExecutionFactory
this.pythonExecutionFactory,
this.serviceContainer.get<INotebookControllerManager>(INotebookControllerManager)
);
kernel.onRestarted(() => this._onDidRestartKernel.fire(kernel), this, this.disposables);
kernel.onDisposed(() => this._onDidDisposeKernel.fire(kernel), this, this.disposables);
Expand Down
6 changes: 6 additions & 0 deletions src/client/datascience/telemetry/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ import { getNormalizedInterpreterPath } from '../../pythonEnvironments/info/inte
* This information is sent with each telemetry event.
*/
type ContextualTelemetryProps = {
/**
* Whether we're starting the preferred kernel or not.
* If false, then the user chose a different kernel when starting the notebook.
* Doesn't really apply to Interactive Window, as we always pick the current interpreter.
*/
isPreferredKernel?: boolean;
kernelConnection: KernelConnectionMetadata;
startFailed: boolean;
kernelDied: boolean;
Expand Down
5 changes: 5 additions & 0 deletions src/client/datascience/telemetry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import { KernelConnectionMetadata } from '../jupyter/kernels/types';

export type ResourceSpecificTelemetryProperties = Partial<{
resourceType: 'notebook' | 'interactive';
/**
* Whether the notebook startup UI (progress indicator & the like) was displayed to the user or not.
* If its not displayed, then its considered an auto start (start in the background, like pre-warming kernel)
*/
disableUI?: boolean;
/**
* Hash of the resource (notebook.uri or pythonfile.uri associated with this).
* If we run the same notebook tomorrow, the hash will be the same.
Expand Down

0 comments on commit 5ea9ffc

Please sign in to comment.