Skip to content

Commit 45b795a

Browse files
authored
Exclude other workspace envs when comparing envs (#23713)
1 parent e9fbc7e commit 45b795a

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import { Event, EventEmitter } from 'vscode';
4+
import { Event, EventEmitter, workspace } from 'vscode';
55
import '../../../../common/extensions';
66
import { createDeferred, Deferred } from '../../../../common/utils/async';
77
import { StopWatch } from '../../../../common/utils/stopWatch';
@@ -277,7 +277,14 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection
277277
}
278278
this.telemetrySentOnce = true;
279279
const { elapsedTime } = stopWatch;
280-
const envs = this.cache.getAllEnvs();
280+
const workspaceFolders = workspace.workspaceFolders || [];
281+
const query: PythonLocatorQuery = {
282+
searchLocations: {
283+
roots: workspaceFolders.map((w) => w.uri),
284+
},
285+
};
286+
287+
const envs = this.getEnvs(workspaceFolders.length ? query : undefined);
281288

282289
const nativeEnvs = [];
283290
const executablesFoundByNativeLocator = new Set<string>();
@@ -485,6 +492,7 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection
485492
// Intent is to capture time taken for discovery of all envs to complete the first time.
486493
sendTelemetryEvent(EventName.PYTHON_INTERPRETER_DISCOVERY, elapsedTime, {
487494
nativeDuration,
495+
workspaceFolderCount: (workspace.workspaceFolders || []).length,
488496
interpreters: this.cache.getAllEnvs().length,
489497
environmentsWithoutPython,
490498
activeStateEnvs,

src/client/telemetry/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,7 @@ export interface IEventNamePropertyMapping {
11411141
*/
11421142
/* __GDPR__
11431143
"python_interpreter_discovery" : {
1144+
"workspaceFolderCount" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
11441145
"duration" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
11451146
"nativeDuration" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
11461147
"interpreters" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true , "owner": "donjayamanne"},
@@ -1195,7 +1196,11 @@ export interface IEventNamePropertyMapping {
11951196
*/
11961197
[EventName.PYTHON_INTERPRETER_DISCOVERY]: {
11971198
/**
1198-
* Time taken to discover using native lcoator.
1199+
* Number of workspaces.
1200+
*/
1201+
workspaceFolderCount?: number;
1202+
/**
1203+
* Time taken to discover using native locator.
11991204
*/
12001205
nativeDuration?: number;
12011206
/**

0 commit comments

Comments
 (0)