From 15b18d8bcba4da937dbf763d56b6362cb851e467 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 11 Jul 2024 17:35:49 +1000 Subject: [PATCH] Performance telemetry for native locator --- .../locators/common/nativePythonTelemetry.ts | 57 ++++++++++++++++++- src/client/telemetry/constants.ts | 1 + src/client/telemetry/index.ts | 50 ++++++++++++++++ 3 files changed, 107 insertions(+), 1 deletion(-) diff --git a/src/client/pythonEnvironments/base/locators/common/nativePythonTelemetry.ts b/src/client/pythonEnvironments/base/locators/common/nativePythonTelemetry.ts index 1bedbaf23699..d7b3150cd748 100644 --- a/src/client/pythonEnvironments/base/locators/common/nativePythonTelemetry.ts +++ b/src/client/pythonEnvironments/base/locators/common/nativePythonTelemetry.ts @@ -5,7 +5,7 @@ import { traceError } from '../../../../logging'; import { sendTelemetryEvent } from '../../../../telemetry'; import { EventName } from '../../../../telemetry/constants'; -export type NativePythonTelemetry = MissingCondaEnvironments | MissingPoetryEnvironments; +export type NativePythonTelemetry = MissingCondaEnvironments | MissingPoetryEnvironments | RefreshPerformance; export type MissingCondaEnvironments = { event: 'MissingCondaEnvironments'; @@ -48,6 +48,37 @@ export type MissingPoetryEnvironments = { }; }; +export type RefreshPerformance = { + event: 'RefreshPerformance'; + data: { + refreshPerformance: { + total: number; + breakdown: { + Locators: number; + Path: number; + GlobalVirtualEnvs: number; + Workspaces: number; + }; + locators: { + Conda?: number; + Homebrew?: number; + LinuxGlobalPython?: number; + MacCmdLineTools?: number; + MacPythonOrg?: number; + MacXCode?: number; + PipEnv?: number; + Poetry?: number; + PyEnv?: number; + Venv?: number; + VirtualEnv?: number; + VirtualEnvWrapper?: number; + WindowsRegistry?: number; + WindowsStore?: number; + }; + }; + }; +}; + export function sendNativeTelemetry(data: NativePythonTelemetry): void { switch (data.event) { case 'MissingCondaEnvironments': { @@ -66,6 +97,30 @@ export function sendNativeTelemetry(data: NativePythonTelemetry): void { ); break; } + case 'RefreshPerformance': { + sendTelemetryEvent(EventName.NATIVE_FINDER_PERF, undefined, { + duration: data.data.refreshPerformance.total, + breakdownGlobalVirtualEnvs: data.data.refreshPerformance.breakdown.GlobalVirtualEnvs, + breakdownLocators: data.data.refreshPerformance.breakdown.Locators, + breakdownPath: data.data.refreshPerformance.breakdown.Path, + breakdownWorkspaces: data.data.refreshPerformance.breakdown.Workspaces, + locatorConda: data.data.refreshPerformance.locators.Conda, + locatorHomebrew: data.data.refreshPerformance.locators.Homebrew, + locatorLinuxGlobalPython: data.data.refreshPerformance.locators.LinuxGlobalPython, + locatorMacCmdLineTools: data.data.refreshPerformance.locators.MacCmdLineTools, + locatorMacPythonOrg: data.data.refreshPerformance.locators.MacPythonOrg, + locatorMacXCode: data.data.refreshPerformance.locators.MacXCode, + locatorPipEnv: data.data.refreshPerformance.locators.PipEnv, + locatorPoetry: data.data.refreshPerformance.locators.Poetry, + locatorPyEnv: data.data.refreshPerformance.locators.PyEnv, + locatorVenv: data.data.refreshPerformance.locators.Venv, + locatorVirtualEnv: data.data.refreshPerformance.locators.VirtualEnv, + locatorVirtualEnvWrapper: data.data.refreshPerformance.locators.VirtualEnvWrapper, + locatorWindowsRegistry: data.data.refreshPerformance.locators.WindowsRegistry, + locatorWindowsStore: data.data.refreshPerformance.locators.WindowsStore, + }); + break; + } default: { traceError(`Unhandled Telemetry Event type ${JSON.stringify(data)}`); } diff --git a/src/client/telemetry/constants.ts b/src/client/telemetry/constants.ts index 69c3a58385d0..b5da8fcc96b7 100644 --- a/src/client/telemetry/constants.ts +++ b/src/client/telemetry/constants.ts @@ -21,6 +21,7 @@ export enum EventName { PYTHON_INTERPRETER_DISCOVERY = 'PYTHON_INTERPRETER_DISCOVERY', NATIVE_FINDER_MISSING_CONDA_ENVS = 'NATIVE_FINDER_MISSING_CONDA_ENVS', NATIVE_FINDER_MISSING_POETRY_ENVS = 'NATIVE_FINDER_MISSING_POETRY_ENVS', + NATIVE_FINDER_PERF = 'NATIVE_FINDER_PERF', PYTHON_INTERPRETER_DISCOVERY_INVALID_NATIVE = 'PYTHON_INTERPRETER_DISCOVERY_INVALID_NATIVE', PYTHON_INTERPRETER_AUTO_SELECTION = 'PYTHON_INTERPRETER_AUTO_SELECTION', PYTHON_INTERPRETER_ACTIVATION_ENVIRONMENT_VARIABLES = 'PYTHON_INTERPRETER.ACTIVATION_ENVIRONMENT_VARIABLES', diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index adf9b1e1059e..d8991b093a79 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -1642,6 +1642,56 @@ export interface IEventNamePropertyMapping { */ inProjectIsDifferent?: boolean; }; + /** + * Telemetry containing performance metrics for Native Finder. + */ + /* __GDPR__ + "native_finder_perf" : { + "duration" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "breakdownLocators" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "breakdownPath" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "breakdownGlobalVirtualEnvs" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "breakdownWorkspaces" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "locatorConda" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "locatorHomebrew" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "locatorLinuxGlobalPython" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "locatorMacCmdLineTools" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "locatorMacPythonOrg" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "locatorMacXCode" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "locatorPipEnv" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "locatorPoetry" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "locatorPyEnv" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "locatorVenv" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "locatorVirtualEnv" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "locatorVirtualEnvWrapper" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "locatorWindowsRegistry" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + "locatorWindowsStore" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" }, + } + */ + [EventName.NATIVE_FINDER_PERF]: { + /** + * Total duration to find envs using native locator. + */ + duration: number; + breakdownLocators?: number; + breakdownPath?: number; + breakdownGlobalVirtualEnvs?: number; + breakdownWorkspaces?: number; + locatorConda?: number; + locatorHomebrew?: number; + locatorLinuxGlobalPython?: number; + locatorMacCmdLineTools?: number; + locatorMacPythonOrg?: number; + locatorMacXCode?: number; + locatorPipEnv?: number; + locatorPoetry?: number; + locatorPyEnv?: number; + locatorVenv?: number; + locatorVirtualEnv?: number; + locatorVirtualEnvWrapper?: number; + locatorWindowsRegistry?: number; + locatorWindowsStore?: number; + }; /** * Telemetry event sent when discovery of all python environments using the native locator(virtualenv, conda, pipenv etc.) finishes. */