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

Native Conda Telemetry #23787

Merged
merged 1 commit into from
Jul 10, 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 @@ -3,7 +3,6 @@

import { Event, EventEmitter, workspace } from 'vscode';
import '../../../../common/extensions';
import * as fsPath from 'path';
import { createDeferred, Deferred } from '../../../../common/utils/async';
import { StopWatch } from '../../../../common/utils/stopWatch';
import { traceError, traceInfo, traceVerbose } from '../../../../logging';
Expand All @@ -29,7 +28,7 @@ import { createNativeGlobalPythonFinder, NativeEnvInfo } from '../common/nativeP
import { pathExists } from '../../../../common/platform/fs-paths';
import { noop } from '../../../../common/utils/misc';
import { parseVersion } from '../../info/pythonVersion';
import { Conda } from '../../../common/environmentManagers/conda';
import { Conda, isCondaEnvironment } from '../../../common/environmentManagers/conda';

/**
* A service which maintains the collection of known environments.
Expand Down Expand Up @@ -310,6 +309,7 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection
envsNotFound: 0,
condaEnvsInEnvDir: 0,
invalidCondaEnvs: 0,
prefixNotExistsCondaEnvs: 0,
condaEnvsWithoutPrefix: 0,
nativeCondaEnvsInEnvDir: 0,
missingNativeCondaEnvs: 0,
Expand Down Expand Up @@ -366,9 +366,9 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection
exe = (await pathExists(env.executable.sysPrefix)) ? env.executable.sysPrefix : '';
}
if (env.executable.sysPrefix && prefixesSeenAlready.has(env.executable.sysPrefix)) {
prefixesSeenAlready.add(env.executable.sysPrefix);
missingEnvironments.envsWithDuplicatePrefixes += 1;
}
prefixesSeenAlready.add(env.executable.sysPrefix);
// Lowercase for purposes of comparison (safe).
exe = exe.trim().toLowerCase();
if (!exe) {
Expand Down Expand Up @@ -491,17 +491,14 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection

await Promise.all(
condaEnvs.map(async (e) => {
if (e.executable.sysPrefix) {
const metadataFolder = fsPath.join(e.executable.sysPrefix, 'conda-meta');
if (!(await pathExists(metadataFolder))) {
missingEnvironments.invalidCondaEnvs += 1;
}
if (e.executable.sysPrefix && !(await pathExists(e.executable.sysPrefix))) {
missingEnvironments.prefixNotExistsCondaEnvs += 1;
}
if (e.executable.filename && (await isCondaEnvironment(e.executable.filename))) {
missingEnvironments.invalidCondaEnvs += 1;
}
}),
);
missingEnvironments.invalidCondaEnvs = envs
.filter((e) => e.kind === PythonEnvKind.Conda)
.filter((e) => e.executable.sysPrefix && e.executable.sysPrefix).length;

const nativeEnvironmentsWithoutPython = nativeEnvs.filter((e) => e.executable === undefined).length;
const nativeCondaEnvs = nativeEnvs.filter(
Expand Down Expand Up @@ -552,6 +549,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: 1,
nativeDuration,
workspaceFolderCount: (workspace.workspaceFolders || []).length,
interpreters: this.cache.getAllEnvs().length,
Expand Down
10 changes: 10 additions & 0 deletions src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ export interface IEventNamePropertyMapping {
*/
/* __GDPR__
"python_interpreter_discovery" : {
"telVer" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"workspaceFolderCount" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"duration" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"nativeDuration" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
Expand All @@ -1152,6 +1153,7 @@ export interface IEventNamePropertyMapping {
"condaEnvsInEnvDir" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true , "owner": "donjayamanne"},
"nativeCondaEnvsInEnvDir" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true , "owner": "donjayamanne"},
"invalidCondaEnvs" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true , "owner": "donjayamanne"},
"prefixNotExistsCondaEnvs" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true , "owner": "donjayamanne"},
"condaEnvsWithoutPrefix" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true , "owner": "donjayamanne"},
"environmentsWithoutPython" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
"usingNativeLocator" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "donjayamanne" },
Expand Down Expand Up @@ -1204,6 +1206,10 @@ export interface IEventNamePropertyMapping {
}
*/
[EventName.PYTHON_INTERPRETER_DISCOVERY]: {
/**
* Version of this telemetry.
*/
telVer?: number;
/**
* Number of workspaces.
*/
Expand Down Expand Up @@ -1242,6 +1248,10 @@ export interface IEventNamePropertyMapping {
* The number of conda interpreters without the `conda-meta` directory.
*/
invalidCondaEnvs?: number;
/**
* The number of conda interpreters that have prefix that doesn't exist on disc.
*/
prefixNotExistsCondaEnvs?: number;
/**
* The number of conda interpreters without the prefix.
*/
Expand Down
Loading