Skip to content

Commit 2316b32

Browse files
karthiknadigCopilot
andcommitted
fix: preserve PET telemetry context (PET #478)
Send numeric PET diagnostics as measurements, classify RPC timeouts by method, preserve refresh failure context, and retry build metadata attribution after transient startup timeouts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 57f4248 commit 2316b32

6 files changed

Lines changed: 316 additions & 117 deletions

File tree

src/common/telemetry/constants.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -603,25 +603,7 @@ export interface IEventNamePropertyMapping {
603603
*/
604604
[EventNames.PET_REFRESH]: {
605605
result: 'success' | 'timeout' | 'error';
606-
envCount?: number;
607-
/** Number of discovered environments whose kind is Conda. Lets us slice refresh duration by conda footprint. */
608-
condaEnvCount?: number;
609-
/** Number of discovered environment managers (conda/pyenv/poetry/etc.). */
610-
managerCount?: number;
611-
unresolvedCount?: number;
612-
workspaceDirCount?: number;
613-
searchPathCount?: number;
614-
attempt: number;
615606
errorType?: string;
616-
// breakdown* fields go through the measures payload (numeric); listed here for GDPR only.
617-
/** ms in the Locators phase. */
618-
breakdownLocators?: number;
619-
/** ms walking PATH env var entries (not a file path). */
620-
breakdownPathEnv?: number;
621-
/** ms scanning global virtual-env dirs. */
622-
breakdownGlobalVirtualEnvs?: number;
623-
/** ms scanning workspace dirs. */
624-
breakdownWorkspaces?: number;
625607
/** JSON-serialized Record<locatorName, ms>. Parse with parse_json() in Kusto. */
626608
locatorsJson?: string;
627609
/** PET crate version reported by the `info` RPC. 'unknown' if the call failed or the PET binary doesn't implement it. */
@@ -638,14 +620,13 @@ export interface IEventNamePropertyMapping {
638620
"workspaceDirCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "eleanorjboyd" },
639621
"envDirCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "eleanorjboyd" },
640622
"retryCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "eleanorjboyd" },
623+
"errorType": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "eleanorjboyd" },
641624
"<duration>": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "eleanorjboyd" }
642625
}
643626
*/
644627
[EventNames.PET_CONFIGURE]: {
645628
result: 'success' | 'timeout' | 'error' | 'skipped';
646-
workspaceDirCount?: number;
647-
envDirCount?: number;
648-
retryCount: number;
629+
errorType?: string;
649630
};
650631

651632
/* __GDPR__
@@ -661,7 +642,6 @@ export interface IEventNamePropertyMapping {
661642
}
662643
*/
663644
[EventNames.PET_PROCESS_RESTART]: {
664-
attempt: number;
665645
result: 'success' | 'error';
666646
errorType?: string;
667647
/**

src/common/telemetry/errorClassifier.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export type DiscoveryErrorType =
1313
| 'command_failed'
1414
| 'connection_error'
1515
| 'rpc_error'
16+
| 'rpc_timeout'
17+
| 'rpc_configure_timeout'
18+
| 'rpc_refresh_timeout'
19+
| 'rpc_resolve_timeout'
1620
| 'process_crash'
1721
| 'already_registered'
1822
| 'unknown';
@@ -27,7 +31,16 @@ export function classifyError(ex: unknown): DiscoveryErrorType {
2731
}
2832

2933
if (ex instanceof RpcTimeoutError) {
30-
return 'spawn_timeout';
34+
switch (ex.method) {
35+
case 'configure':
36+
return 'rpc_configure_timeout';
37+
case 'refresh':
38+
return 'rpc_refresh_timeout';
39+
case 'resolve':
40+
return 'rpc_resolve_timeout';
41+
default:
42+
return 'rpc_timeout';
43+
}
3144
}
3245

3346
// JSON-RPC connection errors (e.g., PET process died mid-request, connection closed/disposed)

0 commit comments

Comments
 (0)