Skip to content

Commit fcd0b0c

Browse files
authored
Add telemetry for #cpp failures (#12910)
1 parent dc81401 commit fcd0b0c

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

Diff for: Extension/src/LanguageServer/lmTool.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTo
5151
}
5252

5353
private async getContext(token: vscode.CancellationToken): Promise<string> {
54+
const telemetryProperties: Record<string, string> = {};
5455
try {
5556
const currentDoc = vscode.window.activeTextEditor?.document;
5657
if (!currentDoc || (!util.isCpp(currentDoc) && !util.isHeaderFile(currentDoc.uri))) {
@@ -62,16 +63,6 @@ export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTo
6263
return 'No configuration information is available for the active document.';
6364
}
6465

65-
telemetry.logLanguageModelToolEvent(
66-
'cpp',
67-
{
68-
"language": chatContext.language,
69-
"compiler": chatContext.compiler,
70-
"standardVersion": chatContext.standardVersion,
71-
"targetPlatform": chatContext.targetPlatform,
72-
"targetArchitecture": chatContext.targetArchitecture
73-
});
74-
7566
for (const key in knownValues) {
7667
const knownKey = key as keyof ChatContextResult;
7768
if (knownValues[knownKey] && chatContext[knownKey]) {
@@ -83,25 +74,33 @@ export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTo
8374
let contextString = "";
8475
if (chatContext.language) {
8576
contextString += `The user is working on a ${chatContext.language} project. `;
77+
telemetryProperties["language"] = chatContext.language;
8678
}
8779
if (chatContext.standardVersion) {
8880
contextString += `The project uses language version ${chatContext.standardVersion}. `;
81+
telemetryProperties["standardVersion"] = chatContext.standardVersion;
8982
}
9083
if (chatContext.compiler) {
9184
contextString += `The project compiles using the ${chatContext.compiler} compiler. `;
85+
telemetryProperties["compiler"] = chatContext.compiler;
9286
}
9387
if (chatContext.targetPlatform) {
9488
contextString += `The project targets the ${chatContext.targetPlatform} platform. `;
89+
telemetryProperties["targetPlatform"] = chatContext.targetPlatform;
9590
}
9691
if (chatContext.targetArchitecture) {
9792
contextString += `The project targets the ${chatContext.targetArchitecture} architecture. `;
93+
telemetryProperties["targetArchitecture"] = chatContext.targetArchitecture;
9894
}
9995

10096
return contextString;
10197
}
10298
catch {
10399
await this.reportError();
100+
telemetryProperties["error"] = "true";
104101
return "";
102+
} finally {
103+
telemetry.logLanguageModelToolEvent('cpp', telemetryProperties);
105104
}
106105
}
107106

0 commit comments

Comments
 (0)