Skip to content

Commit a5c539d

Browse files
authored
Determine reasons for Poetry find failures (#23771)
1 parent d8ae575 commit a5c539d

File tree

3 files changed

+88
-2
lines changed

3 files changed

+88
-2
lines changed

src/client/pythonEnvironments/base/locators/common/nativePythonTelemetry.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { traceError } from '../../../../logging';
55
import { sendTelemetryEvent } from '../../../../telemetry';
66
import { EventName } from '../../../../telemetry/constants';
77

8-
export type NativePythonTelemetry = MissingCondaEnvironments;
8+
export type NativePythonTelemetry = MissingCondaEnvironments | MissingPoetryEnvironments;
99

1010
export type MissingCondaEnvironments = {
1111
event: 'MissingCondaEnvironments';
@@ -30,6 +30,24 @@ export type MissingCondaEnvironments = {
3030
};
3131
};
3232

33+
export type MissingPoetryEnvironments = {
34+
event: 'MissingPoetryEnvironments';
35+
data: {
36+
missingPoetryEnvironments: {
37+
missing: number;
38+
missingInPath: number;
39+
userProvidedPoetryExe?: boolean;
40+
poetryExeNotFound?: boolean;
41+
globalConfigNotFound?: boolean;
42+
cacheDirNotFound?: boolean;
43+
cacheDirIsDifferent?: boolean;
44+
virtualenvsPathNotFound?: boolean;
45+
virtualenvsPathIsDifferent?: boolean;
46+
inProjectIsDifferent?: boolean;
47+
};
48+
};
49+
};
50+
3351
export function sendNativeTelemetry(data: NativePythonTelemetry): void {
3452
switch (data.event) {
3553
case 'MissingCondaEnvironments': {
@@ -40,8 +58,16 @@ export function sendNativeTelemetry(data: NativePythonTelemetry): void {
4058
);
4159
break;
4260
}
61+
case 'MissingPoetryEnvironments': {
62+
sendTelemetryEvent(
63+
EventName.NATIVE_FINDER_MISSING_POETRY_ENVS,
64+
undefined,
65+
data.data.missingPoetryEnvironments,
66+
);
67+
break;
68+
}
4369
default: {
44-
traceError(`Unhandled Telemetry Event type ${data.event}`);
70+
traceError(`Unhandled Telemetry Event type ${JSON.stringify(data)}`);
4571
}
4672
}
4773
}

src/client/telemetry/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export enum EventName {
2020
PYTHON_ENVIRONMENTS_API = 'PYTHON_ENVIRONMENTS_API',
2121
PYTHON_INTERPRETER_DISCOVERY = 'PYTHON_INTERPRETER_DISCOVERY',
2222
NATIVE_FINDER_MISSING_CONDA_ENVS = 'NATIVE_FINDER_MISSING_CONDA_ENVS',
23+
NATIVE_FINDER_MISSING_POETRY_ENVS = 'NATIVE_FINDER_MISSING_POETRY_ENVS',
2324
PYTHON_INTERPRETER_DISCOVERY_INVALID_NATIVE = 'PYTHON_INTERPRETER_DISCOVERY_INVALID_NATIVE',
2425
PYTHON_INTERPRETER_AUTO_SELECTION = 'PYTHON_INTERPRETER_AUTO_SELECTION',
2526
PYTHON_INTERPRETER_ACTIVATION_ENVIRONMENT_VARIABLES = 'PYTHON_INTERPRETER.ACTIVATION_ENVIRONMENT_VARIABLES',

src/client/telemetry/index.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,65 @@ export interface IEventNamePropertyMapping {
14791479
*/
14801480
missingFromOtherRcEnvDirs?: number;
14811481
};
1482+
/**
1483+
* Telemetry event sent when Native finder fails to find some conda envs.
1484+
*/
1485+
/* __GDPR__
1486+
"native_finder_missing_poetry_envs" : {
1487+
"missing" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1488+
"missingInPath" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1489+
"userProvidedPoetryExe" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
1490+
"poetryExeNotFound" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
1491+
"globalConfigNotFound" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
1492+
"cacheDirNotFound" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
1493+
"cacheDirIsDifferent" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
1494+
"virtualenvsPathNotFound" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
1495+
"virtualenvsPathIsDifferent" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
1496+
"inProjectIsDifferent" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
1497+
}
1498+
*/
1499+
[EventName.NATIVE_FINDER_MISSING_POETRY_ENVS]: {
1500+
/**
1501+
* Number of missing poetry environments.
1502+
*/
1503+
missing: number;
1504+
/**
1505+
* Total number of missing envs, where the envs are created in the virtualenvs_path directory.
1506+
*/
1507+
missingInPath: number;
1508+
/**
1509+
* Whether a poetry exe was provided by the user.
1510+
*/
1511+
userProvidedPoetryExe?: boolean;
1512+
/**
1513+
* Whether poetry exe was not found.
1514+
*/
1515+
poetryExeNotFound?: boolean;
1516+
/**
1517+
* Whether poetry config was not found.
1518+
*/
1519+
globalConfigNotFound?: boolean;
1520+
/**
1521+
* Whether cache_dir was not found.
1522+
*/
1523+
cacheDirNotFound?: boolean;
1524+
/**
1525+
* Whether cache_dir found was different from that returned by poetry exe.
1526+
*/
1527+
cacheDirIsDifferent?: boolean;
1528+
/**
1529+
* Whether virtualenvs.path was not found.
1530+
*/
1531+
virtualenvsPathNotFound?: boolean;
1532+
/**
1533+
* Whether virtualenvs.path found was different from that returned by poetry exe.
1534+
*/
1535+
virtualenvsPathIsDifferent?: boolean;
1536+
/**
1537+
* Whether virtualenvs.in-project found was different from that returned by poetry exe.
1538+
*/
1539+
inProjectIsDifferent?: boolean;
1540+
};
14821541
/**
14831542
* Telemetry event sent when discovery of all python environments using the native locator(virtualenv, conda, pipenv etc.) finishes.
14841543
*/

0 commit comments

Comments
 (0)