Skip to content

Commit 415c55b

Browse files
authored
Performance telemetry for native locator (#23792)
1 parent d0e3feb commit 415c55b

File tree

3 files changed

+107
-1
lines changed

3 files changed

+107
-1
lines changed

src/client/pythonEnvironments/base/locators/common/nativePythonTelemetry.ts

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { traceError } from '../../../../logging';
55
import { sendTelemetryEvent } from '../../../../telemetry';
66
import { EventName } from '../../../../telemetry/constants';
77

8-
export type NativePythonTelemetry = MissingCondaEnvironments | MissingPoetryEnvironments;
8+
export type NativePythonTelemetry = MissingCondaEnvironments | MissingPoetryEnvironments | RefreshPerformance;
99

1010
export type MissingCondaEnvironments = {
1111
event: 'MissingCondaEnvironments';
@@ -48,6 +48,37 @@ export type MissingPoetryEnvironments = {
4848
};
4949
};
5050

51+
export type RefreshPerformance = {
52+
event: 'RefreshPerformance';
53+
data: {
54+
refreshPerformance: {
55+
total: number;
56+
breakdown: {
57+
Locators: number;
58+
Path: number;
59+
GlobalVirtualEnvs: number;
60+
Workspaces: number;
61+
};
62+
locators: {
63+
Conda?: number;
64+
Homebrew?: number;
65+
LinuxGlobalPython?: number;
66+
MacCmdLineTools?: number;
67+
MacPythonOrg?: number;
68+
MacXCode?: number;
69+
PipEnv?: number;
70+
Poetry?: number;
71+
PyEnv?: number;
72+
Venv?: number;
73+
VirtualEnv?: number;
74+
VirtualEnvWrapper?: number;
75+
WindowsRegistry?: number;
76+
WindowsStore?: number;
77+
};
78+
};
79+
};
80+
};
81+
5182
export function sendNativeTelemetry(data: NativePythonTelemetry): void {
5283
switch (data.event) {
5384
case 'MissingCondaEnvironments': {
@@ -66,6 +97,30 @@ export function sendNativeTelemetry(data: NativePythonTelemetry): void {
6697
);
6798
break;
6899
}
100+
case 'RefreshPerformance': {
101+
sendTelemetryEvent(EventName.NATIVE_FINDER_PERF, undefined, {
102+
duration: data.data.refreshPerformance.total,
103+
breakdownGlobalVirtualEnvs: data.data.refreshPerformance.breakdown.GlobalVirtualEnvs,
104+
breakdownLocators: data.data.refreshPerformance.breakdown.Locators,
105+
breakdownPath: data.data.refreshPerformance.breakdown.Path,
106+
breakdownWorkspaces: data.data.refreshPerformance.breakdown.Workspaces,
107+
locatorConda: data.data.refreshPerformance.locators.Conda,
108+
locatorHomebrew: data.data.refreshPerformance.locators.Homebrew,
109+
locatorLinuxGlobalPython: data.data.refreshPerformance.locators.LinuxGlobalPython,
110+
locatorMacCmdLineTools: data.data.refreshPerformance.locators.MacCmdLineTools,
111+
locatorMacPythonOrg: data.data.refreshPerformance.locators.MacPythonOrg,
112+
locatorMacXCode: data.data.refreshPerformance.locators.MacXCode,
113+
locatorPipEnv: data.data.refreshPerformance.locators.PipEnv,
114+
locatorPoetry: data.data.refreshPerformance.locators.Poetry,
115+
locatorPyEnv: data.data.refreshPerformance.locators.PyEnv,
116+
locatorVenv: data.data.refreshPerformance.locators.Venv,
117+
locatorVirtualEnv: data.data.refreshPerformance.locators.VirtualEnv,
118+
locatorVirtualEnvWrapper: data.data.refreshPerformance.locators.VirtualEnvWrapper,
119+
locatorWindowsRegistry: data.data.refreshPerformance.locators.WindowsRegistry,
120+
locatorWindowsStore: data.data.refreshPerformance.locators.WindowsStore,
121+
});
122+
break;
123+
}
69124
default: {
70125
traceError(`Unhandled Telemetry Event type ${JSON.stringify(data)}`);
71126
}

src/client/telemetry/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export enum EventName {
2121
PYTHON_INTERPRETER_DISCOVERY = 'PYTHON_INTERPRETER_DISCOVERY',
2222
NATIVE_FINDER_MISSING_CONDA_ENVS = 'NATIVE_FINDER_MISSING_CONDA_ENVS',
2323
NATIVE_FINDER_MISSING_POETRY_ENVS = 'NATIVE_FINDER_MISSING_POETRY_ENVS',
24+
NATIVE_FINDER_PERF = 'NATIVE_FINDER_PERF',
2425
PYTHON_INTERPRETER_DISCOVERY_INVALID_NATIVE = 'PYTHON_INTERPRETER_DISCOVERY_INVALID_NATIVE',
2526
PYTHON_INTERPRETER_AUTO_SELECTION = 'PYTHON_INTERPRETER_AUTO_SELECTION',
2627
PYTHON_INTERPRETER_ACTIVATION_ENVIRONMENT_VARIABLES = 'PYTHON_INTERPRETER.ACTIVATION_ENVIRONMENT_VARIABLES',

src/client/telemetry/index.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,56 @@ export interface IEventNamePropertyMapping {
16421642
*/
16431643
inProjectIsDifferent?: boolean;
16441644
};
1645+
/**
1646+
* Telemetry containing performance metrics for Native Finder.
1647+
*/
1648+
/* __GDPR__
1649+
"native_finder_perf" : {
1650+
"duration" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1651+
"breakdownLocators" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1652+
"breakdownPath" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1653+
"breakdownGlobalVirtualEnvs" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1654+
"breakdownWorkspaces" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1655+
"locatorConda" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1656+
"locatorHomebrew" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1657+
"locatorLinuxGlobalPython" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1658+
"locatorMacCmdLineTools" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1659+
"locatorMacPythonOrg" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1660+
"locatorMacXCode" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1661+
"locatorPipEnv" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1662+
"locatorPoetry" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1663+
"locatorPyEnv" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1664+
"locatorVenv" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1665+
"locatorVirtualEnv" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1666+
"locatorVirtualEnvWrapper" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1667+
"locatorWindowsRegistry" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1668+
"locatorWindowsStore" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "donjayamanne" },
1669+
}
1670+
*/
1671+
[EventName.NATIVE_FINDER_PERF]: {
1672+
/**
1673+
* Total duration to find envs using native locator.
1674+
*/
1675+
duration: number;
1676+
breakdownLocators?: number;
1677+
breakdownPath?: number;
1678+
breakdownGlobalVirtualEnvs?: number;
1679+
breakdownWorkspaces?: number;
1680+
locatorConda?: number;
1681+
locatorHomebrew?: number;
1682+
locatorLinuxGlobalPython?: number;
1683+
locatorMacCmdLineTools?: number;
1684+
locatorMacPythonOrg?: number;
1685+
locatorMacXCode?: number;
1686+
locatorPipEnv?: number;
1687+
locatorPoetry?: number;
1688+
locatorPyEnv?: number;
1689+
locatorVenv?: number;
1690+
locatorVirtualEnv?: number;
1691+
locatorVirtualEnvWrapper?: number;
1692+
locatorWindowsRegistry?: number;
1693+
locatorWindowsStore?: number;
1694+
};
16451695
/**
16461696
* Telemetry event sent when discovery of all python environments using the native locator(virtualenv, conda, pipenv etc.) finishes.
16471697
*/

0 commit comments

Comments
 (0)