Skip to content

Commit eda2b05

Browse files
authored
edits: collect info about uncaught errors from apply_patch processing (#526)
1 parent 8cb779a commit eda2b05

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/extension/tools/node/applyPatchTool.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export class ApplyPatchTool implements ICopilotTool<IApplyPatchToolParams> {
230230
} else if (error instanceof InvalidPatchFormatError) {
231231
this.sendApplyPatchTelemetry(error.kindForTelemetry, options, '', !!healed, !!notebookUri);
232232
} else {
233-
this.sendApplyPatchTelemetry('processPatchFailed', options, error.file, !!healed, !!notebookUri);
233+
this.sendApplyPatchTelemetry('processPatchFailed', options, error.file, !!healed, !!notebookUri, error);
234234
}
235235

236236

@@ -296,7 +296,7 @@ export class ApplyPatchTool implements ICopilotTool<IApplyPatchToolParams> {
296296
notebookEdits.set(result.path, result.edits);
297297
path = result.path;
298298
} catch (error) {
299-
this.sendApplyPatchTelemetry('invalidNotebookEdit', options, altDoc.getText(), !!healed, true);
299+
this.sendApplyPatchTelemetry('invalidNotebookEdit', options, altDoc.getText(), !!healed, true, error);
300300
return new LanguageModelToolResult([
301301
new LanguageModelTextPart('Applying patch failed with error: ' + error.message),
302302
new LanguageModelTextPart(`Use the ${ToolName.EditNotebook} tool to edit notebook files such as ${file}.`),
@@ -418,7 +418,7 @@ export class ApplyPatchTool implements ICopilotTool<IApplyPatchToolParams> {
418418
} catch (error) {
419419
const isNotebook = Object.values(docText).length === 1 ? (!!mapFindFirst(Object.values(docText), v => v.notebookUri)) : undefined;
420420
// TODO parser.ts could annotate DiffError with a telemetry detail if we want
421-
this.sendApplyPatchTelemetry('error', options, undefined, false, isNotebook);
421+
this.sendApplyPatchTelemetry('error', options, undefined, false, isNotebook, error);
422422
return new LanguageModelToolResult([
423423
new LanguageModelTextPart('Applying patch failed with error: ' + error.message),
424424
]);
@@ -529,7 +529,7 @@ export class ApplyPatchTool implements ICopilotTool<IApplyPatchToolParams> {
529529
return { commit };
530530
}
531531

532-
private async sendApplyPatchTelemetry(outcome: string, options: vscode.LanguageModelToolInvocationOptions<IApplyPatchToolParams>, file: string | undefined, healed: boolean, isNotebook: boolean | undefined) {
532+
private async sendApplyPatchTelemetry(outcome: string, options: vscode.LanguageModelToolInvocationOptions<IApplyPatchToolParams>, file: string | undefined, healed: boolean, isNotebook: boolean | undefined, unexpectedError?: Error) {
533533
const model = options.model && (await this.endpointProvider.getChatEndpoint(options.model)).model;
534534

535535
/* __GDPR__
@@ -541,7 +541,8 @@ export class ApplyPatchTool implements ICopilotTool<IApplyPatchToolParams> {
541541
"outcome": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the invocation was successful, or a failure reason" },
542542
"model": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The model that invoked the tool" },
543543
"healed": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the input was healed" },
544-
"isNotebook": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the input was a notebook, 1 = yes, 0 = no, other = Unknown" }
544+
"isNotebook": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the input was a notebook, 1 = yes, 0 = no, other = Unknown" },
545+
"error": { "classification": "CallstackOrException", "purpose": "FeatureInsight", "comment": "Unexpected error that occurrs during application" }
545546
}
546547
*/
547548
this.telemetryService.sendMSFTTelemetryEvent('applyPatchToolInvoked',
@@ -550,6 +551,7 @@ export class ApplyPatchTool implements ICopilotTool<IApplyPatchToolParams> {
550551
interactionId: options.chatRequestId,
551552
outcome,
552553
model,
554+
error: unexpectedError?.stack || unexpectedError?.message,
553555
},
554556
{
555557
healed: healed ? 1 : 0,

0 commit comments

Comments
 (0)