From bfe4c9c2c014c909dd77d3981dfab8710336d9c0 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 7 Jun 2019 12:44:19 -0400 Subject: [PATCH] report: add report versioning This commit adds a version to the diagnostic report feature. PR-URL: https://github.com/nodejs/node/pull/28121 Reviewed-By: Anna Henningsen Reviewed-By: Gireesh Punathil --- doc/api/report.md | 1 + src/node_report.cc | 3 ++- test/common/report.js | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/api/report.md b/doc/api/report.md index 9d773f25ee636f..268caf64160a7d 100644 --- a/doc/api/report.md +++ b/doc/api/report.md @@ -22,6 +22,7 @@ is provided below for reference. ```json { "header": { + "reportVersion": 1, "event": "exception", "trigger": "Exception", "filename": "report.20181221.005011.8974.0.001.json", diff --git a/src/node_report.cc b/src/node_report.cc index b448ffd099bf27..84caf13c5b64d1 100644 --- a/src/node_report.cc +++ b/src/node_report.cc @@ -24,6 +24,7 @@ extern char** environ; #endif +constexpr int NODE_REPORT_VERSION = 1; constexpr int NANOS_PER_SEC = 1000 * 1000 * 1000; constexpr double SEC_PER_MICROS = 1e-6; @@ -172,7 +173,7 @@ static void WriteNodeReport(Isolate* isolate, JSONWriter writer(out); writer.json_start(); writer.json_objectstart("header"); - + writer.json_keyvalue("reportVersion", NODE_REPORT_VERSION); writer.json_keyvalue("event", message); writer.json_keyvalue("trigger", trigger); if (!filename.empty()) diff --git a/test/common/report.js b/test/common/report.js index f415b66dccacfa..7637e5ed956044 100644 --- a/test/common/report.js +++ b/test/common/report.js @@ -63,8 +63,10 @@ function _validateContent(data) { 'nodejsVersion', 'wordSize', 'arch', 'platform', 'componentVersions', 'release', 'osName', 'osRelease', 'osVersion', 'osMachine', 'cpus', 'host', - 'glibcVersionRuntime', 'glibcVersionCompiler', 'cwd']; + 'glibcVersionRuntime', 'glibcVersionCompiler', 'cwd', + 'reportVersion']; checkForUnknownFields(header, headerFields); + assert.strictEqual(header.reportVersion, 1); // Increment as needed. assert.strictEqual(typeof header.event, 'string'); assert.strictEqual(typeof header.trigger, 'string'); assert(typeof header.filename === 'string' || header.filename === null);