Skip to content
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

Additional data to compare conda environments.txt #23805

Merged
merged 2 commits into from
Jul 14, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export type NativeCondaInfo = {
canSpawnConda: boolean;
condaRcs: string[];
envDirs: string[];
environmentsTxt?: string;
environmentsTxtExists?: boolean;
environmentsFromTxt: string[];
};

export interface NativeGlobalPythonFinder extends Disposable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection
nativeCondaEnvDirsNotFound: number;
nativeCondaEnvDirsNotFoundHasEnvs: number;
nativeCondaEnvDirsNotFoundHasEnvsInTxt: number;
nativeCondaEnvTxtSame?: boolean;
nativeCondaEnvTxtExists?: boolean;
nativeCondaEnvsFromTxt: number;
};

const userProvidedCondaExe = fsPath
Expand All @@ -380,11 +383,12 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection
nativeCondaEnvDirsNotFound: 0,
nativeCondaEnvDirsNotFoundHasEnvs: 0,
nativeCondaEnvDirsNotFoundHasEnvsInTxt: 0,
nativeCondaEnvsFromTxt: 0,
};

// Get conda telemetry
{
const [info, nativeCondaInfo, condaEnvsInEnvironmentsTxt] = await Promise.all([
const [info, nativeCondaInfo, condaEnvsInEnvironmentsTxt, envTxt] = await Promise.all([
Conda.getConda()
.catch((ex) => traceError('Failed to get conda info', ex))
.then((conda) => conda?.getInfo()),
Expand All @@ -405,12 +409,20 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection
})
.catch((ex) => traceError(`Failed to get conda envs from environments.txt`, ex))
.then((items) => items || []),
getCondaEnvironmentsTxt().catch(noop),
]);

const environmentsTxt =
Array.isArray(envTxt) && envTxt.length ? fsPath.normalize(envTxt[0]).toLowerCase() : undefined;
if (nativeCondaInfo) {
condaTelemetry.nativeCanSpawnConda = nativeCondaInfo.canSpawnConda;
condaTelemetry.nativeCondaInfoEnvsDirs = new Set(nativeCondaInfo.envDirs).size;
condaTelemetry.nativeCondaRcs = new Set(nativeCondaInfo.condaRcs).size;

const nativeEnvTxt = fsPath.normalize(nativeCondaInfo.environmentsTxt || '').toLowerCase();
condaTelemetry.nativeCondaEnvTxtExists = nativeCondaInfo.environmentsTxtExists === true;
condaTelemetry.nativeCondaEnvsFromTxt = (nativeCondaInfo.environmentsFromTxt || []).length;
condaTelemetry.nativeCondaEnvTxtSame = nativeEnvTxt === environmentsTxt;
}
condaTelemetry.condaEnvsInTxt = condaEnvsInEnvironmentsTxt.length;
condaTelemetry.canSpawnConda = !!info;
Expand Down Expand Up @@ -736,7 +748,7 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection

// Intent is to capture time taken for discovery of all envs to complete the first time.
sendTelemetryEvent(EventName.PYTHON_INTERPRETER_DISCOVERY, elapsedTime, {
telVer: 5,
telVer: 6,
nativeDuration,
workspaceFolderCount: (workspace.workspaceFolders || []).length,
interpreters: this.cache.getAllEnvs().length,
Expand Down
17 changes: 16 additions & 1 deletion src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,10 @@ export interface IEventNamePropertyMapping {
"nativeCondaRcsNotFound" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"nativeCondaEnvDirsNotFound" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"nativeCondaEnvDirsNotFoundHasEnvs" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"nativeCondaEnvDirsNotFoundHasEnvsInTxt" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }
"nativeCondaEnvDirsNotFoundHasEnvsInTxt" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"nativeCondaEnvTxtSame" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
"nativeCondaEnvsFromTxt" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"nativeCondaEnvTxtExists" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" }
}
*/
[EventName.PYTHON_INTERPRETER_DISCOVERY]: {
Expand Down Expand Up @@ -1487,6 +1490,18 @@ export interface IEventNamePropertyMapping {
* Number of environments of a specific type missing in Native Locator (compared to the Stable Locator).
*/
missingNativeCondaEnvs?: number;
/**
* Whether the env txt found by native locator is the same as that found by pythonn ext.
*/
nativeCondaEnvTxtSame?: boolean;
/**
* Number of environments found from env txt by native locator.
*/
nativeCondaEnvsFromTxt?: number;
/**
* Whether the env txt found by native locator exists.
*/
nativeCondaEnvTxtExists?: boolean;
/**
* Number of environments of a specific type missing in Native Locator (compared to the Stable Locator).
*/
Expand Down
Loading