Fix PET timeout telemetry attribution - #1695
Fix PET timeout telemetry attribution#1695Karthik Nadig (karthiknadig) wants to merge 2 commits into
Conversation
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>
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR adjusts PET/setup telemetry so timeout investigations keep numeric measurement context and more accurate timeout attribution (including JSON-RPC method classification), while improving resilience of PET info attribution across restarts.
Changes:
- Move refresh/configure/restart numeric context into telemetry measurements (and add refresh measurement builder helper).
- Classify
RpcTimeoutErrorby JSON-RPC method and update telemetry “timeout vs error” result attribution. - Retry transient PET
infotimeouts with bounded attempts and preserve last-known build metadata across restarts; add unit tests for these behaviors.
Show a summary per file
| File | Description |
|---|---|
| src/managers/common/nativePythonFinder.ts | Adds refresh measurement builder + RPC-timeout retry helper; updates PET telemetry payloads, timeout attribution, and info fetch retry/persistence. |
| src/common/telemetry/errorClassifier.ts | Updates timeout classification to be method-specific for RpcTimeoutError. |
| src/common/telemetry/constants.ts | Adjusts telemetry property mappings to reflect movement of numeric fields into measurements. |
| src/test/managers/common/nativePythonFinder.telemetry.unit.test.ts | Adds unit tests for refresh measurement building and RPC-timeout retry behavior. |
| src/test/common/telemetry/sender.unit.test.ts | Adds regression test asserting sender passes durations as measurements. |
| src/test/common/telemetry/errorClassifier.unit.test.ts | Updates tests to validate method-specific RPC timeout categorization. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 4
- Review effort level: Lite
Isolate PET telemetry helpers, stop metadata retries for superseded connections, clarify GDPR measurement declarations, and map refresh breakdown phases centrally. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Review details
Suppressed comments (4)
src/managers/common/petTelemetry.ts:46
- The conda detection relies on the magic string
'Conda', which can drift from the actualNativePythonEnvironmentKindvalues (e.g., casing changes or enum string values). Consider normalizinginfo.kind(e.g., lowercasing) and comparing against a single canonical value, or accepting both expected representations, socondaEnvCountremains stable if upstream naming changes.
for (const info of input.nativeInfo) {
if (info.tool) {
managerCount++;
} else {
envCount++;
if (info.kind === 'Conda') {
condaEnvCount++;
}
}
}
src/managers/common/nativePythonFinder.ts:777
- With
this.petInfono longer reset onstart(), a newly started PET process can inherit stale build attribution if the PET binary is replaced in-place between restarts (same path, different build) and theinfocall fails (e.g., transient failures). To avoid incorrect attribution, consider invalidatingpetInfowhen you can detect a binary change (e.g., by storing and comparing executable mtime/size, or clearing the cache when the failure indicates an older binary such as a method-not-found response).
connection.listen();
// Stamp PET telemetry with version/buildId/commitSha. Fire-and-forget — must not block refresh.
this.kickoffInfoFetch(connection);
src/managers/common/nativePythonFinder.ts:973
- On refresh failures,
locatorsJson(and any available locator timing context) is not included even whenrefreshPerfmay have partial data. Since the success path includeslocatorsJson, consider also attachinglocatorsJsonin the error path whenrefreshPerfis present to improve failure investigations without changing the numeric measures payload.
{
result: ex instanceof RpcTimeoutError ? 'timeout' : 'error',
errorType,
...this.getPetInfoProperties(),
},
src/managers/common/nativePythonFinder.ts:294
- The new input-validation behavior for
retryRpcTimeout(throwingRangeErrorwhenmaxAttempts < 1or non-integer) isn’t covered by the new unit tests. Add a unit test to assert theRangeErroris thrown for invalid attempt limits (e.g., 0 and 1.5) so the contract stays stable.
if (!Number.isInteger(maxAttempts) || maxAttempts < 1) {
throw new RangeError('maxAttempts must be a positive integer');
}
- Files reviewed: 7/7 changed files
- Comments generated: 0 new
- Review effort level: Lite
Summary
Correct PET/setup telemetry so timeout investigations retain numeric context and reliable binary attribution.
infotimeouts while retaining last known build metadata across restartsValidation
npm run lintnpm run compile-testsnpm run unittest(1500 passing, 5 pending)npm run compileFixes microsoft/python-environment-tools#478