Skip to content

Commit ec0d2bb

Browse files
DonJayamanneeleanorjboyd
authored andcommitted
Additional native finder conda telemetry (microsoft#23788)
1 parent 4f03bd4 commit ec0d2bb

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/client/pythonEnvironments/base/locators/composite/envsCollectionService.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection
330330

331331
let canSpawnConda: boolean | undefined;
332332
let condaInfoEnvs: undefined | number;
333+
let condaInfoEnvsInvalid = 0;
334+
let condaInfoEnvsDuplicate = 0;
335+
let condaInfoEnvsInvalidPrefix = 0;
333336
let condaInfoEnvsDirs: undefined | number;
334337
let envsDirs: string[] = [];
335338
try {
@@ -342,6 +345,22 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection
342345
// eslint-disable-next-line camelcase
343346
envsDirs = info?.envs_dirs || [];
344347

348+
const duplicate = new Set<string>();
349+
Promise.all(
350+
(info?.envs || []).map(async (e) => {
351+
if (duplicate.has(e)) {
352+
condaInfoEnvsDuplicate += 1;
353+
return;
354+
}
355+
duplicate.add(e);
356+
if (!(await pathExists(e))) {
357+
condaInfoEnvsInvalidPrefix += 1;
358+
}
359+
if (!(await isCondaEnvironment(e))) {
360+
condaInfoEnvsInvalid += 1;
361+
}
362+
}),
363+
);
345364
nativeEnvs
346365
.filter((e) => this.nativeFinder.categoryToKind(e.kind) === PythonEnvKind.Conda)
347366
.forEach((e) => {
@@ -549,7 +568,10 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection
549568

550569
// Intent is to capture time taken for discovery of all envs to complete the first time.
551570
sendTelemetryEvent(EventName.PYTHON_INTERPRETER_DISCOVERY, elapsedTime, {
552-
telVer: 1,
571+
telVer: 2,
572+
condaInfoEnvsInvalid,
573+
condaInfoEnvsDuplicate,
574+
condaInfoEnvsInvalidPrefix,
553575
nativeDuration,
554576
workspaceFolderCount: (workspace.workspaceFolders || []).length,
555577
interpreters: this.cache.getAllEnvs().length,

src/client/telemetry/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,9 @@ export interface IEventNamePropertyMapping {
11451145
"workspaceFolderCount" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
11461146
"duration" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
11471147
"nativeDuration" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1148+
"condaInfoEnvsInvalid" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1149+
"condaInfoEnvsDuplicate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1150+
"condaInfoEnvsInvalidPrefix" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
11481151
"interpreters" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true , "owner": "donjayamanne"},
11491152
"envsWithDuplicatePrefixes" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true , "owner": "donjayamanne"},
11501153
"envsNotFound" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true , "owner": "donjayamanne"},
@@ -1210,6 +1213,18 @@ export interface IEventNamePropertyMapping {
12101213
* Version of this telemetry.
12111214
*/
12121215
telVer?: number;
1216+
/**
1217+
* Number of invalid envs returned by `conda info`
1218+
*/
1219+
condaInfoEnvsInvalid?: number;
1220+
/**
1221+
* Number of duplicate envs returned by `conda info`
1222+
*/
1223+
condaInfoEnvsDuplicate?: number;
1224+
/**
1225+
* Number of envs with invalid prefix returned by `conda info`
1226+
*/
1227+
condaInfoEnvsInvalidPrefix?: number;
12131228
/**
12141229
* Number of workspaces.
12151230
*/

0 commit comments

Comments
 (0)