Skip to content

Commit

Permalink
Enhance Telemetry reporting (#1272)
Browse files Browse the repository at this point in the history
* update telemetry add error fields and category

* add category for all error notify calls

* add flag for optional telemetry logger error notify

* fix lint

* add installZipFile validation

* fix lint
  • Loading branch information
brianignacio5 authored Sep 30, 2024
1 parent 9725ba3 commit eef0677
Show file tree
Hide file tree
Showing 69 changed files with 499 additions and 245 deletions.
15 changes: 9 additions & 6 deletions src/build/buildCmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export async function buildCommand(
);
Logger.errorNotify(
waitProcessIsFinishedMsg,
new Error("One_Task_At_A_Time")
new Error("One_Task_At_A_Time"),
"buildCmd buildCommand"
);
return;
}
Expand Down Expand Up @@ -80,27 +81,29 @@ export async function buildCommand(
return Logger.warnNotify(
`The selected device target "${adapterTargetName}" is not compatible for DFU, as a result the DFU.bin was not created.`
);
} else {
await buildTask.buildDfu();
await TaskManager.runTasks();
}
await buildTask.buildDfu();
await TaskManager.runTasks();
}
if (!cancelToken.isCancellationRequested) {
updateIdfComponentsTree(workspace);
Logger.infoNotify("Build Successfully");
const flashCmd = await buildFinishFlashCmd(workspace);
OutputChannel.appendLineAndShow(flashCmd, "Build");
OutputChannel.appendLine(flashCmd, "Build");
TaskManager.disposeListeners();
}
} catch (error) {
if (error.message === "ALREADY_BUILDING") {
return Logger.errorNotify("Already a build is running!", error);
return Logger.errorNotify("Already a build is running!", error, "buildCommand");
}
if (error.message === "BUILD_TERMINATED") {
return Logger.warnNotify(`Build is Terminated`);
}
Logger.errorNotify(
"Something went wrong while trying to build the project",
error
error,
"buildCommand"
);
continueFlag = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/build/buildTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class BuildTask {
} catch (error) {
const errorMessage =
"Failed to save unsaved files, ignoring and continuing with the build";
Logger.error(errorMessage, error);
Logger.error(errorMessage, error, "build saveBeforeBuild");
Logger.warnNotify(errorMessage);
}
if (BuildTask.isBuilding) {
Expand Down
2 changes: 1 addition & 1 deletion src/cdtDebugAdapter/debugConfProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class CDTDebugConfigurationProvider
const msg = error.message
? error.message
: "Some build files doesn't exist. Build this project first.";
Logger.error(msg, error);
Logger.error(msg, error, "CDTDebugConfigurationProvider");
return;
}
return config;
Expand Down
11 changes: 8 additions & 3 deletions src/changelog-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ export namespace ChangelogViewer {
Uri.file(changelogFilePath)
);
} catch (error) {
Logger.errorNotify("Failed to open the CHANGELOG.md file", error, {
sev: 1,
});
Logger.errorNotify(
"Failed to open the CHANGELOG.md file",
error,
"showChangeLogAndUpdateVersion",
{
sev: 1,
}
);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/checkExtensionSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function checkExtensionSettings(
const msg = error.message
? error.message
: "Checking if current install is valid throws an error.";
Logger.error(msg, error);
Logger.error(msg, error, "checkExtensionSettings");
}
const notificationMode = readParameter(
"idf.notificationMode",
Expand Down Expand Up @@ -107,7 +107,7 @@ export async function checkExtensionSettings(
const msg = error.message
? error.message
: "Error loading initial configuration.";
Logger.errorNotify(msg, error);
Logger.errorNotify(msg, error, "checkExtensionSettings");
if (showSetupWindow) {
vscode.commands.executeCommand("espIdf.setup.start");
}
Expand Down
2 changes: 1 addition & 1 deletion src/cmake/cmakeEditorPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class CmakeListsEditorPanel {
fileName: fileUri.fsPath,
});
} catch (error) {
Logger.errorNotify(`Failed reading ${fileUri.fsPath}`, error);
Logger.errorNotify(`Failed reading ${fileUri.fsPath}`, error, "CmakeListsEditorPanel loadCMakeListSchema");
}
case "saveChanges":
if (message.newValues) {
Expand Down
2 changes: 1 addition & 1 deletion src/cmake/srcsWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class UpdateCmakeLists {
? error.message
: "Error updating srcs in CMakeLists.txt";
this.writeFinished();
Logger.error(msg, error);
Logger.error(msg, error, "updateSrcsInCmakeLists");
}
}
);
Expand Down
6 changes: 3 additions & 3 deletions src/common/abstractCloning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class AbstractCloning {
Logger.infoNotify(`${this.name} has been installed`);
} catch (error) {
OutputChannel.appendLine(error.message);
Logger.errorNotify(error.message, error);
Logger.errorNotify(error.message, error, "AbstractCloning getRepository");
}
}
);
Expand Down Expand Up @@ -377,7 +377,7 @@ export class AbstractCloning {
if (!signal && code !== 0) {
const msg = `Submodules clone has exit with ${code}`;
OutputChannel.appendLine(msg);
Logger.errorNotify("Submodules cloning error", new Error(msg));
Logger.errorNotify("Submodules cloning error", new Error(msg), "AbstractCloning spawnWithProgress");
return reject(new Error(msg));
}
return resolve();
Expand Down Expand Up @@ -414,7 +414,7 @@ export class AbstractCloning {
Logger.infoNotify(`${repoName} submodules checked out successfully`);
} catch (error) {
OutputChannel.appendLine(error.message);
Logger.errorNotify(error.message, error);
Logger.errorNotify(error.message, error, "AbstractCloning getSubmodules");
}
}
);
Expand Down
4 changes: 2 additions & 2 deletions src/component-manager/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export async function addDependency(
{ dependency, component }
)
);
Logger.error(error.message, error);
Logger.error(error.message, error, "Component manager addDependency");
throw throwableError;
}
}
Expand Down Expand Up @@ -109,7 +109,7 @@ export async function createProject(
{ example }
)}. Original error: ${error.message}`
);
Logger.error(error.message, error);
Logger.error(error.message, error, "Component manager createProject");
throw throwableError;
}
}
6 changes: 4 additions & 2 deletions src/coverage/coverageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ export async function generateCoverageForEditors(
"Error generate editor coverage.\n" +
"Check the ESP-IDF output for more details." +
msg,
error
error,
"coverageService generateCoverageForEditors"
);
OutputChannel.appendLine(
msg +
Expand Down Expand Up @@ -190,7 +191,8 @@ export async function previewReport(dirPath: vscode.Uri) {
Logger.errorNotify(
"Error building gcov html.\n" +
"Check the ESP-IDF output for more details.",
e
e,
"coverageService previewReport"
);
OutputChannel.appendLine(
msg +
Expand Down
2 changes: 1 addition & 1 deletion src/coverage/gcdaPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export async function getGcovData(workspaceFolder: Uri) {
(err, stdout, stderr) => {
if (err) {
const msg = err && err.message ? err.message : err;
Logger.error(`exec error: ${msg}`, err);
Logger.error(`exec error: ${msg}`, err, "gcdaPaths getGcovData");
return reject(err);
}
const output = [];
Expand Down
2 changes: 1 addition & 1 deletion src/downloadManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class DownloadManager {
const errMsg = error.message
? error.message
: `Error downloading ${urlToUse}`;
Logger.error(errMsg, error);
Logger.error(errMsg, error, "downloadManager downloadWithRetries");
retryCount += 1;
if (cancelToken && cancelToken.isCancellationRequested) {
throw error;
Expand Down
2 changes: 1 addition & 1 deletion src/efuse/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class ESPEFuseManager {
);
const eFuseFields = await readJson(tempFile);
unlink(tempFile, (err) => {
Logger.error("Failed to delete the tmp espfuse json file", err);
Logger.error("Failed to delete the tmp espfuse json file", err, "ESPEFuseManager summary");
});
const resp = {};
for (const name in eFuseFields) {
Expand Down
2 changes: 1 addition & 1 deletion src/espBom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export async function createSBOM(workspaceUri: Uri) {
const msg = error.message
? error.message
: "Error create SBOM Report or check vulnerabilities.";
Logger.errorNotify(msg, error);
Logger.errorNotify(msg, error, "createSBOM");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/espIdf/arduino/addArduinoComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class ArduinoComponentInstaller {
if (!signal && code !== 0) {
const errorMsg = `Arduino ESP32 cloning has exit with ${code}`;
OutputChannel.appendLine(errorMsg);
Logger.errorNotify(errorMsg, new Error(errorMsg));
Logger.errorNotify(errorMsg, new Error(errorMsg), "addArduinoComponent cloneArduinoInComponentsFolder");
reject(new Error(errorMsg));
}
resolve();
Expand Down
3 changes: 2 additions & 1 deletion src/espIdf/communications/ws/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ export class WSServer extends EventEmitter {
} catch (error) {
Logger.errorNotify(
`Failed to parse the websocket message`,
error
error,
"WSServer start"
);
this.emit("unknown-message", data, error);
}
Expand Down
2 changes: 1 addition & 1 deletion src/espIdf/core-dump/esp-core-dump-py-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class ESPCoreDumpPyTool {
);
return true;
} catch (error) {
Logger.error("espcoredump.py failed", error, { output: resp.toString() });
Logger.error("espcoredump.py failed", error, "ESPCoreDumpPyTool generateCoreELFFile", { output: resp.toString() });
return false;
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/espIdf/debugAdapter/debugAdapterManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ export class DebugAdapterManager extends EventEmitter {
if (!signal && code && code !== 0) {
Logger.errorNotify(
`ESP-IDF Debug Adapter exit with error code ${code}`,
new Error("Spawn exit with non-zero" + code)
new Error("Spawn exit with non-zero" + code),
"DebugAdapterManager start"
);
}
this.stop();
Expand Down Expand Up @@ -326,7 +327,11 @@ export class DebugAdapterManager extends EventEmitter {
return resultGdbInitPath;
}
} catch (error) {
Logger.errorNotify("Error creating gdbinit file", error);
Logger.errorNotify(
"Error creating gdbinit file",
error,
"DebugAdapterManager makeGdbinitFile"
);
}
return;
}
Expand Down
18 changes: 13 additions & 5 deletions src/espIdf/debugAdapter/peripheralTreeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ export class PeripheralTreeForSession extends PeripheralBaseNode {
this.errMessage = `Unable to parse SVD file ${
this.svdFileName
}: ${e.toString()}`;
Logger.errorNotify(this.errMessage, new Error(this.errMessage));
Logger.errorNotify(
this.errMessage,
new Error(this.errMessage),
"PeripheralTreeForSession sessionStarted"
);
if (debug.activeDebugConsole) {
debug.activeDebugConsole.appendLine(this.errMessage);
}
Expand Down Expand Up @@ -278,8 +282,10 @@ export class PeripheralTreeView
}
if (this.sessionPeripheralsMap.get(session.id)) {
this._onDidChangeTreeData.fire(undefined);
const err = new Error(`Internal Error: Session ${session.name} id=${session.id} already in the tree view?`)
Logger.errorNotify(err.message, err);
const err = new Error(
`Internal Error: Session ${session.name} id=${session.id} already in the tree view?`
);
Logger.errorNotify(err.message, err, "peripheralTreeView debugSessionStarted alreadyInTreeView");
resolve(undefined);
return;
}
Expand All @@ -297,8 +303,10 @@ export class PeripheralTreeView
try {
await regs.sessionStarted(svdFilePath, thresh); // Should never reject
} catch (e) {
const err = new Error(`Internal Error: Unexpected rejection of promise ${e}`);
Logger.errorNotify(err.message, err);
const err = new Error(
`Internal Error: Unexpected rejection of promise ${e}`
);
Logger.errorNotify(err.message, err, "peripheralTreeView debugSessionStarted");
} finally {
this._onDidChangeTreeData.fire(undefined);
}
Expand Down
2 changes: 1 addition & 1 deletion src/espIdf/debugAdapter/verifyApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export async function verifyAppBinary(workspaceFolder: Uri) {
const msg = error.message
? error.message
: "Something wrong while verifying app binary.";
Logger.errorNotify(msg, error);
Logger.errorNotify(msg, error, "verifyAppBinary");
return false;
}
}
3 changes: 2 additions & 1 deletion src/espIdf/documentation/docResultsTreeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export class DocSearchResultTreeDataProvider
if (!url) {
Logger.errorNotify(
"Cannot call this command directly, click on any ESP-IDF search result!",
new Error("INVALID_INVOCATION")
new Error("INVALID_INVOCATION"),
"DocSearchResultTreeDataProvider espIdf.openDocUrl"
);
return;
}
Expand Down
5 changes: 3 additions & 2 deletions src/espIdf/documentation/getDocsVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export async function getDocsVersion() {
} catch (error) {
Logger.error(
`Error parsing object from ${ESP.URL.Docs.IDF_VERSIONS}`,
error
error,
"getDocsVersion"
);
}
}
Expand All @@ -65,7 +66,7 @@ export function getDocsLocaleLang() {
const localeConf = JSON.parse(process.env.VSCODE_NLS_CONFIG);
localeLang = localeConf.locale === "zh-CN" ? "zh_CN" : "en";
} catch (error) {
Logger.error("Error getting current vscode language", error);
Logger.error("Error getting current vscode language", error, "getDocsVersion getDocsLocaleLang");
}
return localeLang;
}
Expand Down
3 changes: 2 additions & 1 deletion src/espIdf/hints/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ export class ErrorHintProvider implements vscode.TreeDataProvider<ErrorHint> {
} catch (error) {
Logger.errorNotify(
`Error processing hints file (line ${error.mark?.line}): ${error.message}`,
error
error,
"ErrorHintProvider searchError"
);
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/espIdf/menuconfig/MenuconfigPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class MenuConfigPanel {
progress
);
} catch (error) {
Logger.errorNotify(error.message, error);
Logger.errorNotify(error.message, error, "MenuConfigPanel setDefaultValues");
}
}
);
Expand Down Expand Up @@ -205,7 +205,7 @@ export class MenuConfigPanel {
const err = new Error(
`Menuconfig: Unrecognized command received, file: ${__filename}`
);
Logger.error(err.message, err);
Logger.error(err.message, err, "MenuconfigPanel Unrecognized command");
break;
}
});
Expand All @@ -226,7 +226,7 @@ export class MenuConfigPanel {

if (jsonValues.error) {
const err = new Error(`Invalid data error: ${jsonValues.error}`);
Logger.error(err.message, err);
Logger.error(err.message, err, "MenuconfigPanel updateConfigValues");
return;
}
const updatedMenus = ConfserverProcess.updateValues(values);
Expand Down
4 changes: 2 additions & 2 deletions src/espIdf/menuconfig/confServerProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export class ConfserverProcess {
if (code !== 0) {
const errorMsg = `When loading default values received exit signal: ${signal}, code : ${code}`;
OutputChannel.appendLine(errorMsg, "SDK Configuration Editor");
Logger.error(errorMsg, new Error(errorMsg));
Logger.error(errorMsg, new Error(errorMsg), "ConfserverProcess setDefaultValues");
}
ConfserverProcess.init(currWorkspace, extensionPath);
progress.report({ increment: 70, message: "The end" });
Expand Down Expand Up @@ -425,6 +425,6 @@ export class ConfserverProcess {
OutputChannel.appendLine(
"-----------------------END OF ERROR-----------------------"
);
Logger.error(data.toString(), new Error(data.toString()));
Logger.error(data.toString(), new Error(data.toString()), "ConfserverProcess printError");
}
}
Loading

0 comments on commit eef0677

Please sign in to comment.