Skip to content

Commit

Permalink
Determine reasons for Poetry find failures (#23771)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored Jul 9, 2024
1 parent d8ae575 commit a5c539d
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { traceError } from '../../../../logging';
import { sendTelemetryEvent } from '../../../../telemetry';
import { EventName } from '../../../../telemetry/constants';

export type NativePythonTelemetry = MissingCondaEnvironments;
export type NativePythonTelemetry = MissingCondaEnvironments | MissingPoetryEnvironments;

export type MissingCondaEnvironments = {
event: 'MissingCondaEnvironments';
Expand All @@ -30,6 +30,24 @@ export type MissingCondaEnvironments = {
};
};

export type MissingPoetryEnvironments = {
event: 'MissingPoetryEnvironments';
data: {
missingPoetryEnvironments: {
missing: number;
missingInPath: number;
userProvidedPoetryExe?: boolean;
poetryExeNotFound?: boolean;
globalConfigNotFound?: boolean;
cacheDirNotFound?: boolean;
cacheDirIsDifferent?: boolean;
virtualenvsPathNotFound?: boolean;
virtualenvsPathIsDifferent?: boolean;
inProjectIsDifferent?: boolean;
};
};
};

export function sendNativeTelemetry(data: NativePythonTelemetry): void {
switch (data.event) {
case 'MissingCondaEnvironments': {
Expand All @@ -40,8 +58,16 @@ export function sendNativeTelemetry(data: NativePythonTelemetry): void {
);
break;
}
case 'MissingPoetryEnvironments': {
sendTelemetryEvent(
EventName.NATIVE_FINDER_MISSING_POETRY_ENVS,
undefined,
data.data.missingPoetryEnvironments,
);
break;
}
default: {
traceError(`Unhandled Telemetry Event type ${data.event}`);
traceError(`Unhandled Telemetry Event type ${JSON.stringify(data)}`);
}
}
}
1 change: 1 addition & 0 deletions src/client/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum EventName {
PYTHON_ENVIRONMENTS_API = 'PYTHON_ENVIRONMENTS_API',
PYTHON_INTERPRETER_DISCOVERY = 'PYTHON_INTERPRETER_DISCOVERY',
NATIVE_FINDER_MISSING_CONDA_ENVS = 'NATIVE_FINDER_MISSING_CONDA_ENVS',
NATIVE_FINDER_MISSING_POETRY_ENVS = 'NATIVE_FINDER_MISSING_POETRY_ENVS',
PYTHON_INTERPRETER_DISCOVERY_INVALID_NATIVE = 'PYTHON_INTERPRETER_DISCOVERY_INVALID_NATIVE',
PYTHON_INTERPRETER_AUTO_SELECTION = 'PYTHON_INTERPRETER_AUTO_SELECTION',
PYTHON_INTERPRETER_ACTIVATION_ENVIRONMENT_VARIABLES = 'PYTHON_INTERPRETER.ACTIVATION_ENVIRONMENT_VARIABLES',
Expand Down
59 changes: 59 additions & 0 deletions src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,65 @@ export interface IEventNamePropertyMapping {
*/
missingFromOtherRcEnvDirs?: number;
};
/**
* Telemetry event sent when Native finder fails to find some conda envs.
*/
/* __GDPR__
"native_finder_missing_poetry_envs" : {
"missing" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"missingInPath" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"userProvidedPoetryExe" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
"poetryExeNotFound" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
"globalConfigNotFound" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
"cacheDirNotFound" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
"cacheDirIsDifferent" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
"virtualenvsPathNotFound" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
"virtualenvsPathIsDifferent" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
"inProjectIsDifferent" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
}
*/
[EventName.NATIVE_FINDER_MISSING_POETRY_ENVS]: {
/**
* Number of missing poetry environments.
*/
missing: number;
/**
* Total number of missing envs, where the envs are created in the virtualenvs_path directory.
*/
missingInPath: number;
/**
* Whether a poetry exe was provided by the user.
*/
userProvidedPoetryExe?: boolean;
/**
* Whether poetry exe was not found.
*/
poetryExeNotFound?: boolean;
/**
* Whether poetry config was not found.
*/
globalConfigNotFound?: boolean;
/**
* Whether cache_dir was not found.
*/
cacheDirNotFound?: boolean;
/**
* Whether cache_dir found was different from that returned by poetry exe.
*/
cacheDirIsDifferent?: boolean;
/**
* Whether virtualenvs.path was not found.
*/
virtualenvsPathNotFound?: boolean;
/**
* Whether virtualenvs.path found was different from that returned by poetry exe.
*/
virtualenvsPathIsDifferent?: boolean;
/**
* Whether virtualenvs.in-project found was different from that returned by poetry exe.
*/
inProjectIsDifferent?: boolean;
};
/**
* Telemetry event sent when discovery of all python environments using the native locator(virtualenv, conda, pipenv etc.) finishes.
*/
Expand Down

0 comments on commit a5c539d

Please sign in to comment.