Skip to content
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
27 changes: 5 additions & 22 deletions src/common/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,27 +601,10 @@ export interface IEventNamePropertyMapping {
"<duration>": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "eleanorjboyd" }
}
*/
// Numeric fields declared in the GDPR block are sent through the measurements payload.
[EventNames.PET_REFRESH]: {
result: 'success' | 'timeout' | 'error';
envCount?: number;
/** Number of discovered environments whose kind is Conda. Lets us slice refresh duration by conda footprint. */
condaEnvCount?: number;
/** Number of discovered environment managers (conda/pyenv/poetry/etc.). */
managerCount?: number;
unresolvedCount?: number;
workspaceDirCount?: number;
searchPathCount?: number;
attempt: number;
errorType?: string;
// breakdown* fields go through the measures payload (numeric); listed here for GDPR only.
/** ms in the Locators phase. */
breakdownLocators?: number;
/** ms walking PATH env var entries (not a file path). */
breakdownPathEnv?: number;
/** ms scanning global virtual-env dirs. */
breakdownGlobalVirtualEnvs?: number;
/** ms scanning workspace dirs. */
breakdownWorkspaces?: number;
/** JSON-serialized Record<locatorName, ms>. Parse with parse_json() in Kusto. */
locatorsJson?: string;
/** PET crate version reported by the `info` RPC. 'unknown' if the call failed or the PET binary doesn't implement it. */
Comment thread
karthiknadig marked this conversation as resolved.
Expand All @@ -638,14 +621,14 @@ export interface IEventNamePropertyMapping {
"workspaceDirCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "eleanorjboyd" },
"envDirCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "eleanorjboyd" },
"retryCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "eleanorjboyd" },
"errorType": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "eleanorjboyd" },
"<duration>": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "eleanorjboyd" }
}
*/
// Numeric fields declared in the GDPR block are sent through the measurements payload.
[EventNames.PET_CONFIGURE]: {
result: 'success' | 'timeout' | 'error' | 'skipped';
workspaceDirCount?: number;
envDirCount?: number;
retryCount: number;
errorType?: string;
};

/* __GDPR__
Expand All @@ -660,8 +643,8 @@ export interface IEventNamePropertyMapping {
"<duration>": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "eleanorjboyd" }
}
*/
// `attempt` is declared in the GDPR block and sent through the measurements payload.
[EventNames.PET_PROCESS_RESTART]: {
attempt: number;
result: 'success' | 'error';
errorType?: string;
/**
Expand Down
21 changes: 20 additions & 1 deletion src/common/telemetry/errorClassifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ export type DiscoveryErrorType =
| 'command_failed'
| 'connection_error'
| 'rpc_error'
| 'rpc_timeout'
| 'rpc_configure_timeout'
| 'rpc_refresh_timeout'
| 'rpc_resolve_timeout'
| 'process_crash'
| 'already_registered'
| 'unknown';

/** Returns true for spawn and JSON-RPC timeout telemetry categories. */
export function isTimeoutErrorType(errorType: DiscoveryErrorType): boolean {
return errorType === 'spawn_timeout' || errorType === 'rpc_timeout' ||
(errorType.startsWith('rpc_') && errorType.endsWith('_timeout'));
}

/**
* Classifies an error into a telemetry-safe category for the `errorType` property.
* Does NOT include raw error messages — only the category.
Expand All @@ -27,7 +37,16 @@ export function classifyError(ex: unknown): DiscoveryErrorType {
}

if (ex instanceof RpcTimeoutError) {
return 'spawn_timeout';
switch (ex.method) {
case 'configure':
return 'rpc_configure_timeout';
case 'refresh':
return 'rpc_refresh_timeout';
case 'resolve':
return 'rpc_resolve_timeout';
default:
return 'rpc_timeout';
}
}

// JSON-RPC connection errors (e.g., PET process died mid-request, connection closed/disposed)
Expand Down
4 changes: 2 additions & 2 deletions src/internal.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { CreateEnvironmentNotSupported, RemoveEnvironmentNotSupported } from './
import { traceWarn } from './common/logging';
import { StopWatch } from './common/stopWatch';
import { EventNames } from './common/telemetry/constants';
import { classifyError } from './common/telemetry/errorClassifier';
import { classifyError, isTimeoutErrorType } from './common/telemetry/errorClassifier';
import { sendTelemetryEvent } from './common/telemetry/sender';

export type EnvironmentManagerScope = undefined | string | Uri | PythonEnvironment;
Expand Down Expand Up @@ -242,7 +242,7 @@ export class InternalEnvironmentManager implements EnvironmentManager {
duration,
{
managerId: this.id,
result: errorType === 'canceled' || errorType === 'spawn_timeout' ? 'timeout' : 'error',
result: errorType === 'canceled' || isTimeoutErrorType(errorType) ? 'timeout' : 'error',
errorType,
},
ex instanceof Error ? ex : undefined,
Expand Down
Loading
Loading