bug 1470493 - Render "event" ping events in about:telemetry r=janerik a=lizzard l10n=adding-strings-back-removed-in-bug-1460595 DEVEDITION_62_0b7_BUILD1 DEVEDITION_62_0b7_RELEASE FENNEC_62_0b7_BUILD1 FENNEC_62_0b7_RELEASE FIREFOX_62_0b7_BUILD1 FIREFOX_62_0b7_RELEASE
authorChris H-C <chutten@mozilla.com>
Mon, 02 Jul 2018 08:55:12 +0000
changeset 815706 32cde6cdb297933f18c086dfa4d6aed28a239a1a
parent 815705 3281d05908701c28a17589cadaec3550b430029b
child 815707 ccb7e0878cb5f45a29aedd183ede106c4cb8940e
child 815831 34e9acac2e4b97e4cf610f3f4244c9ae361e2f9d
push id115612
push userbmo:andrei.br92@gmail.com
push dateMon, 09 Jul 2018 18:14:16 +0000
reviewersjanerik, lizzard
bugs1470493, 1460595
milestone62.0
bug 1470493 - Render "event" ping events in about:telemetry r=janerik a=lizzard l10n=adding-strings-back-removed-in-bug-1460595 MozReview-Commit-ID: 8U54Cs6obOs Differential Revision: https://phabricator.services.mozilla.com/D1882
toolkit/content/aboutTelemetry.js
toolkit/content/aboutTelemetry.xhtml
toolkit/locales/en-US/chrome/global/aboutTelemetry.dtd
toolkit/locales/en-US/chrome/global/aboutTelemetry.properties
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -374,20 +374,29 @@ var PingPicker = {
         await this._updateArchivedPingList(archivedPingList);
         document.getElementById("archived-ping-picker").hidden = false;
       }
     }
   },
 
   _updateCurrentPingData() {
     const subsession = document.getElementById("show-subsession-data").checked;
-    const ping = TelemetryController.getCurrentPingData(subsession);
+    let ping = TelemetryController.getCurrentPingData(subsession);
     if (!ping) {
       return;
     }
+
+    // augment ping payload with event telemetry
+    let eventSnapshot = Telemetry.snapshotEvents(Telemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
+    for (let process of Object.keys(eventSnapshot)) {
+      if (process in ping.payload.processes) {
+        ping.payload.processes[process].events = eventSnapshot[process].filter(e => !e[1].startsWith("telemetry.test"));
+      }
+    }
+
     displayPingData(ping, true);
   },
 
   _updateArchivedPingData() {
     let id = this._getSelectedPingId();
     let res = Promise.resolve();
     if (id) {
       res = TelemetryArchive.promiseArchivedPingById(id)
@@ -1703,16 +1712,57 @@ var KeyedScalars = {
       // Populate the section with the key-value pairs from the scalar.
       const table = GenericTable.render(explodeObject(keyedScalars[scalar]), headings);
       container.appendChild(table);
       scalarsSection.appendChild(container);
     }
   },
 };
 
+var Events = {
+  /**
+   * Render the event data - if present - from the payload in a simple table.
+   * @param aPayload A payload object to render the data from.
+   */
+  render(aPayload) {
+    let eventsSection = document.getElementById("events");
+    removeAllChildNodes(eventsSection);
+
+    let processesSelect = document.getElementById("processes");
+    let selectedProcess = processesSelect.selectedOptions.item(0).getAttribute("value");
+
+    if (!aPayload.processes ||
+        !selectedProcess ||
+        !(selectedProcess in aPayload.processes)) {
+      return;
+    }
+
+    let events = aPayload.processes[selectedProcess].events || {};
+    let hasData = Array.from(processesSelect.options).some((option) => {
+      let value = option.getAttribute("value");
+      let evts = aPayload.processes[value].events;
+      return evts && Object.keys(evts).length > 0;
+    });
+    setHasData("events-section", hasData);
+    if (Object.keys(events).length > 0) {
+      const headings = [
+        "timestampHeader",
+        "categoryHeader",
+        "methodHeader",
+        "objectHeader",
+        "valuesHeader",
+        "extraHeader",
+      ].map(h => bundle.GetStringFromName(h));
+
+      const table = GenericTable.render(events, headings);
+      eventsSection.appendChild(table);
+    }
+  },
+};
+
 /**
  * Helper function for showing either the toggle element or "No data collected" message for a section
  *
  * @param aSectionID ID of the section element that needs to be changed
  * @param aHasData true (default) indicates that toggle should be displayed
  */
 function setHasData(aSectionID, aHasData) {
   let sectionElement = document.getElementById(aSectionID);
@@ -2301,16 +2351,19 @@ function displayRichPingData(ping, updat
   KeyedScalars.render(payload);
 
   // Show histogram data
   HistogramSection.render(payload);
 
   // Show keyed histogram data
   KeyedHistogramSection.render(payload);
 
+  // Show event data.
+  Events.render(payload);
+
   // Show captured stacks.
   CapturedStacks.render(payload);
 
   LateWritesSingleton.renderLateWrites(payload.lateWrites);
 
   // Show simple measurements
   SimpleMeasurements.render(payload);
 
--- a/toolkit/content/aboutTelemetry.xhtml
+++ b/toolkit/content/aboutTelemetry.xhtml
@@ -52,16 +52,19 @@
         <span class="category-name">&aboutTelemetry.keyedScalarsSection;</span>
       </div>
       <div class="category" value="histograms-section">
         <span class="category-name">&aboutTelemetry.histogramsSection;</span>
       </div>
       <div class="category" value="keyed-histograms-section">
         <span class="category-name">&aboutTelemetry.keyedHistogramsSection;</span>
       </div>
+      <div class="category" value="events-section">
+        <span class="category-name">&aboutTelemetry.eventsSection;</span>
+      </div>
       <div class="category" value="simple-measurements-section">
         <span class="category-name">&aboutTelemetry.simpleMeasurementsSection;</span>
       </div>
       <div class="category" value="slow-sql-section">
         <span class="category-name">&aboutTelemetry.slowSqlSection;</span>
       </div>
       <div class="category" value="addon-details-section">
         <span class="category-name">&aboutTelemetry.addonDetailsSection;</span>
--- a/toolkit/locales/en-US/chrome/global/aboutTelemetry.dtd
+++ b/toolkit/locales/en-US/chrome/global/aboutTelemetry.dtd
@@ -29,16 +29,17 @@
 <!ENTITY aboutTelemetry.homeSection "Home">
 <!ENTITY aboutTelemetry.generalDataSection "General Data">
 <!ENTITY aboutTelemetry.environmentDataSection "Environment Data">
 <!ENTITY aboutTelemetry.sessionInfoSection "Session Information">
 <!ENTITY aboutTelemetry.scalarsSection "Scalars">
 <!ENTITY aboutTelemetry.keyedScalarsSection "Keyed Scalars">
 <!ENTITY aboutTelemetry.histogramsSection "Histograms">
 <!ENTITY aboutTelemetry.keyedHistogramsSection "Keyed Histograms">
+<!ENTITY aboutTelemetry.eventsSection "Events">
 <!ENTITY aboutTelemetry.simpleMeasurementsSection "Simple Measurements">
 <!ENTITY aboutTelemetry.slowSqlSection "Slow SQL Statements">
 <!ENTITY aboutTelemetry.addonDetailsSection "Add-on Details">
 <!ENTITY aboutTelemetry.capturedStacksSection "Captured Stacks">
 <!ENTITY aboutTelemetry.lateWritesSection "Late Writes">
 <!ENTITY aboutTelemetry.rawPayloadSection "Raw Payload">
 <!ENTITY aboutTelemetry.raw "Raw JSON">
 
--- a/toolkit/locales/en-US/chrome/global/aboutTelemetry.properties
+++ b/toolkit/locales/en-US/chrome/global/aboutTelemetry.properties
@@ -89,8 +89,13 @@ captured-stacks-title = %1$S (capture co
 # - %1$S is replaced by the number of the late write
 late-writes-title = Late Write #%1$S
 
 stackTitle = Stack:
 memoryMapTitle = Memory map:
 
 errorFetchingSymbols = An error occurred while fetching symbols. Check that you are connected to the Internet and try again.
 
+timestampHeader = timestamp
+categoryHeader = category
+methodHeader = method
+objectHeader = object
+extraHeader = extra