-
Notifications
You must be signed in to change notification settings - Fork 38
feat: enhance telemetry with error classification and duration tracking for environment manager registration #1292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eleanorjboyd
wants to merge
6
commits into
microsoft:main
Choose a base branch
from
eleanorjboyd:gothic-vicuna
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4f0c673
feat: enhance telemetry with error classification and duration tracki…
eleanorjboyd ab57b73
address comments
eleanorjboyd 19b1ee3
Merge branch 'main' into gothic-vicuna
eleanorjboyd 0a0706f
cleanup
eleanorjboyd b10cb5c
Merge remote-tracking branch 'upstream/main' into gothic-vicuna
eleanorjboyd 1df677a
logging to determine CI error
eleanorjboyd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { CancellationError } from 'vscode'; | ||
| import { RpcTimeoutError } from '../../managers/common/nativePythonFinder'; | ||
|
|
||
| export type DiscoveryErrorType = | ||
| | 'spawn_timeout' | ||
| | 'spawn_enoent' | ||
| | 'permission_denied' | ||
| | 'canceled' | ||
| | 'parse_error' | ||
| | 'unknown'; | ||
|
|
||
| /** | ||
| * Classifies an error into a telemetry-safe category for the `errorType` property. | ||
| * Does NOT include raw error messages — only the category. | ||
| */ | ||
| export function classifyError(ex: unknown): DiscoveryErrorType { | ||
| if (ex instanceof CancellationError) { | ||
| return 'canceled'; | ||
| } | ||
|
|
||
| if (ex instanceof RpcTimeoutError) { | ||
| return 'spawn_timeout'; | ||
| } | ||
|
|
||
| if (!(ex instanceof Error)) { | ||
| return 'unknown'; | ||
| } | ||
|
|
||
| // Check error code for spawn failures (Node.js sets `code` on spawn errors) | ||
| const code = (ex as NodeJS.ErrnoException).code; | ||
| if (code === 'ENOENT') { | ||
| return 'spawn_enoent'; | ||
| } | ||
| if (code === 'EACCES' || code === 'EPERM') { | ||
| return 'permission_denied'; | ||
| } | ||
|
|
||
| // Check message patterns | ||
| const msg = ex.message.toLowerCase(); | ||
| if (msg.includes('timed out') || msg.includes('timeout')) { | ||
| return 'spawn_timeout'; | ||
| } | ||
| if (msg.includes('parse') || msg.includes('unexpected token') || msg.includes('json')) { | ||
| return 'parse_error'; | ||
| } | ||
|
|
||
| // Check error name for cancellation variants | ||
| if (ex.name === 'CancellationError' || ex.name === 'AbortError') { | ||
| return 'canceled'; | ||
| } | ||
|
|
||
| return 'unknown'; | ||
| } | ||
eleanorjboyd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import assert from 'node:assert'; | ||
| import { CancellationError } from 'vscode'; | ||
| import { classifyError } from '../../../common/telemetry/errorClassifier'; | ||
| import { RpcTimeoutError } from '../../../managers/common/nativePythonFinder'; | ||
|
|
||
| suite('Error Classifier', () => { | ||
| suite('classifyError', () => { | ||
| test('should classify CancellationError as canceled', () => { | ||
| assert.strictEqual(classifyError(new CancellationError()), 'canceled'); | ||
| }); | ||
|
|
||
| test('should classify RpcTimeoutError as spawn_timeout', () => { | ||
| assert.strictEqual(classifyError(new RpcTimeoutError('resolve', 30000)), 'spawn_timeout'); | ||
| }); | ||
|
|
||
| test('should classify non-Error values as unknown', () => { | ||
| assert.strictEqual(classifyError('string error'), 'unknown'); | ||
| assert.strictEqual(classifyError(42), 'unknown'); | ||
| assert.strictEqual(classifyError(null), 'unknown'); | ||
| assert.strictEqual(classifyError(undefined), 'unknown'); | ||
| }); | ||
|
|
||
| test('should classify ENOENT errors as spawn_enoent', () => { | ||
| const err = new Error('spawn python ENOENT') as NodeJS.ErrnoException; | ||
| err.code = 'ENOENT'; | ||
| assert.strictEqual(classifyError(err), 'spawn_enoent'); | ||
| }); | ||
|
|
||
| test('should classify EACCES errors as permission_denied', () => { | ||
| const err = new Error('permission denied') as NodeJS.ErrnoException; | ||
| err.code = 'EACCES'; | ||
| assert.strictEqual(classifyError(err), 'permission_denied'); | ||
| }); | ||
|
|
||
| test('should classify EPERM errors as permission_denied', () => { | ||
| const err = new Error('operation not permitted') as NodeJS.ErrnoException; | ||
| err.code = 'EPERM'; | ||
| assert.strictEqual(classifyError(err), 'permission_denied'); | ||
| }); | ||
|
|
||
| test('should classify timeout messages as spawn_timeout', () => { | ||
| assert.strictEqual(classifyError(new Error('Request timed out')), 'spawn_timeout'); | ||
| assert.strictEqual(classifyError(new Error('Connection timeout')), 'spawn_timeout'); | ||
| }); | ||
|
|
||
| test('should classify parse errors as parse_error', () => { | ||
| assert.strictEqual(classifyError(new Error('Failed to parse output')), 'parse_error'); | ||
| assert.strictEqual(classifyError(new Error('Unexpected token < in JSON')), 'parse_error'); | ||
| assert.strictEqual(classifyError(new Error('Invalid JSON response')), 'parse_error'); | ||
| }); | ||
|
|
||
| test('should classify AbortError name as canceled', () => { | ||
| const err = new Error('aborted'); | ||
| err.name = 'AbortError'; | ||
| assert.strictEqual(classifyError(err), 'canceled'); | ||
| }); | ||
|
|
||
| test('should classify error with CancellationError name as canceled', () => { | ||
| const err = new Error('cancelled'); | ||
| err.name = 'CancellationError'; | ||
| assert.strictEqual(classifyError(err), 'canceled'); | ||
| }); | ||
|
|
||
| test('should classify unrecognized errors as unknown', () => { | ||
| assert.strictEqual(classifyError(new Error('something went wrong')), 'unknown'); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.