bug 1338627 - Add crashTime to crash pings data-review=bsmedberg r?gsvelto draft
authorChris H-C <chutten@mozilla.com>
Thu, 16 Feb 2017 13:13:38 -0500
changeset 491990 790415418530632aeb8d8a4c62151ac0053ed932
parent 491989 d9a06d9da18bbbe51eaf98bcdd978c89ced5362c
child 547599 c68425ab3d22d81df605a3286281fb2f6532df4d
push id47471
push userbmo:chutten@mozilla.com
push dateThu, 02 Mar 2017 15:09:25 +0000
reviewersgsvelto
bugs1338627
milestone54.0a1
bug 1338627 - Add crashTime to crash pings data-review=bsmedberg r?gsvelto crashDate having only per-day resolution was making client delay analysis rather inaccurate. crashTime is an ISO8601 string with per-hour resolution which should smooth things over on the analysis side. If per-hour is still too coarse, the use of an ISO string allows us to adapt later to increasing the resolution, if it passes data review. The underlying crash timestamp has per-second resolution. MozReview-Commit-ID: 2hwJHSi8Xje
toolkit/components/crashes/CrashManager.jsm
toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
toolkit/components/telemetry/docs/data/crash-ping.rst
toolkit/crashreporter/client/ping.cpp
--- a/toolkit/components/crashes/CrashManager.jsm
+++ b/toolkit/components/crashes/CrashManager.jsm
@@ -646,16 +646,17 @@ this.CrashManager.prototype = Object.fre
 
     // Filter the remaining annotations to remove privacy-sensitive ones
     reportMeta = this._filterAnnotations(reportMeta);
 
     this._pingPromise = TelemetryController.submitExternalPing("crash",
       {
         version: 1,
         crashDate: date.toISOString().slice(0, 10), // YYYY-MM-DD
+        crashTime: date.toISOString().slice(0, 13) + ":00:00.000Z", // per-hour resolution
         sessionId,
         crashId,
         processType: type,
         stackTraces,
         metadata: reportMeta,
         hasCrashEnvironment: (crashEnvironment !== null),
       },
       {
--- a/toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
+++ b/toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
@@ -471,16 +471,22 @@ add_task(function* test_content_crash_pi
   yield m._pingPromise;
 
   let found = yield ac.promiseFindPing("crash", [
     [["payload", "crashId"], id],
     [["payload", "processType"], m.PROCESS_TYPE_CONTENT],
     [["payload", "stackTraces", "status"], "OK"],
   ]);
   Assert.ok(found, "Telemetry ping submitted for content crash");
+
+  let hoursOnly = new Date(DUMMY_DATE);
+  hoursOnly.setSeconds(0);
+  hoursOnly.setMinutes(0);
+  Assert.equal(new Date(found.payload.crashTime).getTime(), hoursOnly.getTime());
+
   Assert.equal(found.payload.metadata.ThisShouldNot, undefined,
                "Non-whitelisted fields should be filtered out");
 });
 
 add_task(function* test_generateSubmissionID() {
   let m = yield getManager();
 
   const SUBMISSION_ID_REGEX =
--- a/toolkit/components/telemetry/docs/data/crash-ping.rst
+++ b/toolkit/components/telemetry/docs/data/crash-ping.rst
@@ -26,16 +26,17 @@ Structure:
     {
       type: "crash",
       ... common ping data
       clientId: <UUID>,
       environment: { ... },
       processType: <type>, // Type of process that crashed, see below for a list of types
       payload: {
         crashDate: "YYYY-MM-DD",
+        crashTime: <ISO Date>, // per-hour resolution
         version: 1,
         sessionId: <UUID>, // may be missing for crashes that happen early
                            // in startup. Added in Firefox 48 with the
                            // intention of uplifting to Firefox 46
         crashId: <UUID>, // Optional, ID of the associated crash
         stackTraces: { ... }, // Optional, see below
         metadata: { // Annotations saved while Firefox was running. See nsExceptionHandler.cpp for more information
           ProductID: "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
--- a/toolkit/crashreporter/client/ping.cpp
+++ b/toolkit/crashreporter/client/ping.cpp
@@ -89,16 +89,17 @@ GenerateUUID()
   if (num != kUUIDFormatStringLength) {
     return "";
   }
 
   return str;
 }
 
 const char kISO8601Date[] = "%F";
+const char kISO8601DateHours[] = "%FT%H:00:00.000Z";
 const char kISO8601FullDate[] = "%FT%T.000Z";
 
 // Return the current date as a string in the specified format, the following
 // constants are provided:
 // - kISO8601Date, the ISO 8601 date format, YYYY-MM-DD
 // - kISO8601FullDate, the ISO 8601 full date format, YYYY-MM-DDTHH:MM:SS.000Z
 static string
 CurrentDate(string format)
@@ -165,16 +166,17 @@ CreateMetadataNode(StringTable& strings)
 static Json::Value
 CreatePayloadNode(StringTable& strings, const string& aSessionId)
 {
   Json::Value payload;
 
   payload["sessionId"] = aSessionId;
   payload["version"] = 1;
   payload["crashDate"] = CurrentDate(kISO8601Date);
+  payload["crashTime"] = CurrentDate(kISO8601DateHours);
   payload["hasCrashEnvironment"] = true;
   payload["crashId"] = GetDumpLocalID();
   payload["processType"] = "main"; // This is always a main crash
 
   // Parse the stack traces
   Json::Value stackTracesValue;
   Json::Reader reader;