Skip to content

Commit

Permalink
Better telemetry when installing Jupyter dependencies (microsoft#16272)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored Jun 5, 2021
1 parent 547243f commit acdc241
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/1 Enhancements/15937.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improved telemetry around the availability of `pip` for installation of Jupyter dependencies.
19 changes: 19 additions & 0 deletions src/client/common/installer/productInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ export class FormatterInstaller extends BaseInstaller {
product: Product,
resource?: Uri,
cancel?: CancellationToken,
_flags?: ModuleInstallFlags,
): Promise<InstallerResponse> {
// Hard-coded on purpose because the UI won't necessarily work having
// another formatter.
Expand Down Expand Up @@ -318,6 +319,7 @@ export class LinterInstaller extends BaseInstaller {
product: Product,
resource?: Uri,
cancel?: CancellationToken,
_flags?: ModuleInstallFlags,
): Promise<InstallerResponse> {
sendTelemetryEvent(EventName.LINTER_INSTALL_PROMPT, undefined, {
prompt: 'old',
Expand Down Expand Up @@ -408,6 +410,7 @@ export class TestFrameworkInstaller extends BaseInstaller {
product: Product,
resource?: Uri,
cancel?: CancellationToken,
_flags?: ModuleInstallFlags,
): Promise<InstallerResponse> {
const productName = ProductNames.get(product)!;

Expand All @@ -430,6 +433,7 @@ class RefactoringLibraryInstaller extends BaseInstaller {
product: Product,
resource?: Uri,
cancel?: CancellationToken,
_flags?: ModuleInstallFlags,
): Promise<InstallerResponse> {
const productName = ProductNames.get(product)!;
const item = await this.appShell.showErrorMessage(
Expand Down Expand Up @@ -466,23 +470,34 @@ class DataScienceInstaller extends BaseInstaller {
const moduleName = translateProductToModule(product, ModuleNamePurpose.install);
let installerModule: IModuleInstaller | undefined;
const isAvailableThroughConda = !UnsupportedChannelsForProduct.get(product)?.has(EnvironmentType.Conda);
let requiredInstaller = 'unknown';
if (interpreter.envType === EnvironmentType.Conda && isAvailableThroughConda) {
installerModule = channels.find((v) => v.name === EnvironmentType.Conda);
requiredInstaller = EnvironmentType.Conda;
} else if (interpreter.envType === EnvironmentType.Conda && !isAvailableThroughConda) {
// This case is temporary and can be removed when https://github.com/microsoft/vscode-jupyter/issues/5034 is unblocked
traceInfo(
`Interpreter type is conda but package ${moduleName} is not available through conda, using pip instead.`,
);
installerModule = channels.find((v) => v.name === 'Pip');
requiredInstaller = 'pip';
} else {
installerModule = channels.find((v) => v.name === 'Pip');
requiredInstaller = 'pip';
}

const version = `${interpreter.version?.major || ''}.${interpreter.version?.minor || ''}.${
interpreter.version?.patch || ''
}`;

if (!installerModule) {
this.appShell.showErrorMessage(Installer.couldNotInstallLibrary().format(moduleName)).then(noop, noop);
sendTelemetryEvent(EventName.PYTHON_INSTALL_PACKAGE, undefined, {
installer: 'unavailable',
requiredInstaller,
productName: ProductNames.get(product),
version,
envType: interpreter.envType,
});
return InstallerResponse.Ignore;
}
Expand All @@ -494,6 +509,9 @@ class DataScienceInstaller extends BaseInstaller {
return this.isInstalled(product, interpreter).then((isInstalled) => {
sendTelemetryEvent(EventName.PYTHON_INSTALL_PACKAGE, undefined, {
installer: installerModule?.displayName || '',
requiredInstaller,
version,
envType: interpreter.envType,
isInstalled,
productName: ProductNames.get(product),
});
Expand All @@ -509,6 +527,7 @@ class DataScienceInstaller extends BaseInstaller {
product: Product,
resource?: InterpreterUri,
cancel?: CancellationToken,
_flags?: ModuleInstallFlags,
): Promise<InstallerResponse> {
const productName = ProductNames.get(product)!;
const item = await this.appShell.showErrorMessage(
Expand Down
14 changes: 13 additions & 1 deletion src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { DebugConfigurationType } from '../debugger/extension/types';
import { ConsoleType, TriggerType } from '../debugger/types';
import { AutoSelectionRule } from '../interpreter/autoSelection/types';
import { LinterId } from '../linters/types';
import { EnvironmentType } from '../pythonEnvironments/info';
import { EnvironmentType, PythonEnvironment } from '../pythonEnvironments/info';
import {
TensorBoardPromptSelection,
TensorBoardEntrypointTrigger,
Expand Down Expand Up @@ -839,6 +839,10 @@ export interface IEventNamePropertyMapping {
* One of the possible values includes `unavailable`, meaning user doesn't have pip, conda, or other tools available that can be used to install a python package.
*/
installer: string;
/**
* The name of the installer required (expected to be available) for installation of pacakges. (pipenv, Conda etc.)
*/
requiredInstaller?: string;
/**
* Name of the corresponding product (package) to be installed.
*/
Expand All @@ -847,6 +851,14 @@ export interface IEventNamePropertyMapping {
* Whether the product (package) has been installed or not.
*/
isInstalled?: boolean;
/**
* Type of the Python environment into which the Python package is being installed.
*/
envType?: PythonEnvironment['envType'];
/**
* Version of the Python environment into which the Python package is being installed.
*/
version?: string;
};
/**
* Telemetry sent with details immediately after linting a document completes
Expand Down

0 comments on commit acdc241

Please sign in to comment.