bug 1470493 - Render "event" ping events in about:telemetry r=janerik
authorChris H-C <chutten@mozilla.com>
Mon, 02 Jul 2018 08:55:12 +0000
changeset 424879 dc761197f10da38be188b211c09eb43bbd291d1f
parent 424878 0ca12229796251caf4f12ab02a043259fd382e17
child 424880 2ea1193c44b9e5da22605295c184cc4a9f5c8a8f
push id104933
push usershindli@mozilla.com
push dateTue, 03 Jul 2018 22:35:47 +0000
treeherdermozilla-inbound@00de580e868f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanerik
bugs1470493
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1470493 - Render "event" ping events in about:telemetry r=janerik 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