Skip to content

feat: add triggerReason to pet.process_restart and globalScopeDeferred to setup.hang_detected#1508

Open
eleanorjboyd wants to merge 5 commits into
microsoft:mainfrom
eleanorjboyd:married-monkey
Open

feat: add triggerReason to pet.process_restart and globalScopeDeferred to setup.hang_detected#1508
eleanorjboyd wants to merge 5 commits into
microsoft:mainfrom
eleanorjboyd:married-monkey

Conversation

@eleanorjboyd
Copy link
Copy Markdown
Member

@eleanorjboyd eleanorjboyd commented May 6, 2026

  • pet.process_restart now emits triggerReason (process_exit::, process_error, rpc_connection_error, rpc_refresh_timeout, rpc_resolve_timeout, rpc_configure_timeout, start_failed, unknown) so we can distinguish crash restarts from timeout restarts.
  • setup.hang_detected now emits globalScopeDeferred (true/false/undefined) so we can tell whether a watchdog trip was a real foreground hang or a background global-scope scan running past 120s after the user already had an env selected

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

eleanorjboyd and others added 2 commits May 6, 2026 16:12
…d to setup.hang_detected

- pet.process_restart now emits triggerReason (process_exit:<code>:<signal>,
  process_error, rpc_connection_error, rpc_refresh_timeout, rpc_resolve_timeout,
  rpc_configure_timeout, start_failed, unknown) so we can distinguish crash
  restarts from timeout restarts in Kusto
- setup.hang_detected now emits globalScopeDeferred (true/false/undefined) so
  we can tell whether a watchdog trip was a real foreground hang or a background
  global-scope scan running past 120s after the user already had an env selected
- Updated GDPR declarations and TypeScript types in constants.ts for both events
- Thread globalScopeDeferredRef through applyInitialEnvironmentSelection so the
  hang watchdog can read the deferred flag before envSelection returns

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… pet.refresh telemetry

PET already sends a 'telemetry' JSON-RPC notification with RefreshPerformance
data after each refresh call. We were discarding it. Now we listen for it and
include the per-phase and per-locator timings in our pet.refresh event.

New fields on pet.refresh:
- breakdownLocators / breakdownPath / breakdownGlobalVirtualEnvs / breakdownWorkspaces
  (isMeasurement, ms) — the 4 parallel discovery phases from PET's breakdown map
- locatorsJson (string) — JSON-serialized per-locator durations (Conda, WindowsRegistry,
  WindowsStore, etc.); query in Kusto with parse_json(Properties.locatorsJson)

This lets us slice slow-cohort p90s by locator/phase to answer which Windows
discovery path is responsible for the 11% slowdown (WindowsRegistry, WindowsStore,
Conda, etc.) without any changes on PET's side.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@eleanorjboyd eleanorjboyd self-assigned this May 6, 2026
@eleanorjboyd eleanorjboyd added the debt Code quality issues label May 6, 2026
@eleanorjboyd eleanorjboyd requested a review from Copilot May 6, 2026 23:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances telemetry around PET restarts and activation hang detection to better attribute why PET restarted and whether setup hangs are related to deferred global-scope environment resolution.

Changes:

  • Add triggerReason to pet.process_restart telemetry to distinguish restarts caused by exit vs RPC timeouts/errors.
  • Track whether global-scope resolution was deferred during initial environment selection and include it in setup.hang_detected telemetry.
  • Extend telemetry schema (constants.ts) to include the new properties in GDPR mappings and typings.
Show a summary per file
File Description
src/managers/common/nativePythonFinder.ts Tracks PET exit/restart reasons and includes triggerReason in restart telemetry.
src/features/interpreterSelection.ts Adds a mutable ref to record whether global-scope resolution was deferred vs awaited.
src/extension.ts Plumbs globalScopeDeferred into hang watchdog telemetry via a shared ref.
src/common/telemetry/constants.ts Updates telemetry schema/GDPR mapping for globalScopeDeferred and triggerReason.

Copilot's findings

Comments suppressed due to low confidence (1)

src/managers/common/nativePythonFinder.ts:545

  • The error handler sets processExitReason = 'process_error' unconditionally; if a more-specific reason was already recorded (e.g., an RPC timeout/connection error followed by a kill), this will overwrite it and reduce the fidelity of triggerReason telemetry. Consider only setting this when processExitReason is still undefined.
            // Handle process errors (e.g., ENOENT if executable not found)
            this.proc.on('error', (err) => {
                this.processExited = true;
                this.processExitReason = 'process_error';
                this.outputChannel.error('[pet] Process error:', err);
  • Files reviewed: 4/4 changed files
  • Comments generated: 5

Comment thread src/managers/common/nativePythonFinder.ts Outdated
Comment thread src/extension.ts
Comment thread src/common/telemetry/constants.ts Outdated
Comment thread src/common/telemetry/constants.ts Outdated
Comment thread src/features/interpreterSelection.ts
@eleanorjboyd eleanorjboyd requested a review from Copilot May 11, 2026 18:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 3

Comment thread src/managers/common/nativePythonFinder.ts Outdated
Comment thread src/managers/common/nativePythonFinder.ts
Comment thread src/managers/common/nativePythonFinder.ts
@eleanorjboyd eleanorjboyd marked this pull request as ready for review May 11, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debt Code quality issues skip tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants