bug 1163971 - Add a simple select to about:telemetry to allow viewing child payloads, when present. r=gfritzsche
authorChris H-C <chutten@mozilla.com>
Thu, 29 Oct 2015 07:36:00 +0100
changeset 270334 31e72022d3ff5f5f5a13969427cba902cca2dcfd
parent 270333 5fc57433f68a53e8418a361706e3ea936a37290b
child 270335 78f8c8c84ccde32d1b7799e4ccf6358bcceb9971
push id29611
push userkwierso@gmail.com
push dateFri, 30 Oct 2015 23:16:47 +0000
treeherdermozilla-central@eb49e19d2e06 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1163971
milestone45.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 1163971 - Add a simple select to about:telemetry to allow viewing child payloads, when present. r=gfritzsche
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
@@ -293,16 +293,19 @@ var PingPicker = {
     document.getElementById("choose-ping-id").addEventListener("change", () => {
       this._updateArchivedPingData()
     }, false);
 
     document.getElementById("newer-ping")
             .addEventListener("click", () => this._movePingIndex(-1), false);
     document.getElementById("older-ping")
             .addEventListener("click", () => this._movePingIndex(1), false);
+
+    document.getElementById("choose-payload")
+            .addEventListener("change", () => displayPingData(gPingData), false);
   },
 
   onPingSourceChanged: function() {
     this.update();
   },
 
   update: function() {
     let el = document.getElementById("ping-source-current");
@@ -317,23 +320,23 @@ var PingPicker = {
       this._updateArchivedPingList().then(() =>
         document.getElementById("archived-ping-picker").classList.remove("hidden"));
     }
   },
 
   _updateCurrentPingData: function() {
     const subsession = document.getElementById("show-subsession-data").checked;
     const ping = TelemetryController.getCurrentPingData(subsession);
-    displayPingData(ping);
+    displayPingData(ping, true);
   },
 
   _updateArchivedPingData: function() {
     let id = this._getSelectedPingId();
     TelemetryArchive.promiseArchivedPingById(id)
-                    .then((ping) => displayPingData(ping));
+                    .then((ping) => displayPingData(ping, true));
   },
 
   _updateArchivedPingList: function() {
     return TelemetryArchive.promiseArchivedPingList().then((pingList) => {
       // The archived ping list is sorted in ascending timestamp order,
       // but descending is more practical for the operations we do here.
       pingList.reverse();
 
@@ -1526,22 +1529,59 @@ function sortStartupMilestones(aSimpleMe
   let result = {};
   for (let key of sortedKeys) {
     result[key] = aSimpleMeasurements[key];
   }
 
   return result;
 }
 
-function displayPingData(ping) {
+function renderPayloadList(ping) {
+  // Rebuild the payload select with options:
+  //   Parent Payload (selected)
+  //   Child Payload 1..ping.payload.childPayloads.length
+  let listEl = document.getElementById("choose-payload");
+  removeAllChildNodes(listEl);
+
+  let option = document.createElement("option");
+  let text = bundle.GetStringFromName("parentPayload");
+  let content = document.createTextNode(text);
+  let payloadIndex = 0;
+  option.appendChild(content);
+  option.setAttribute("value", payloadIndex++);
+  option.selected = true;
+  listEl.appendChild(option);
+
+  if (!ping.payload.childPayloads) {
+    listEl.disabled = true;
+    return
+  }
+  listEl.disabled = false;
+
+  for (; payloadIndex <= ping.payload.childPayloads.length; ++payloadIndex) {
+    option = document.createElement("option");
+    text = bundle.formatStringFromName("childPayload", [payloadIndex], 1);
+    content = document.createTextNode(text);
+    option.appendChild(content);
+    option.setAttribute("value", payloadIndex);
+    listEl.appendChild(option);
+  }
+}
+
+function displayPingData(ping, updatePayloadList = false) {
   gPingData = ping;
 
   const keysHeader = bundle.GetStringFromName("keysHeader");
   const valuesHeader = bundle.GetStringFromName("valuesHeader");
 
+  // Update the payload list
+  if (updatePayloadList) {
+    renderPayloadList(ping);
+  }
+
   // Show general data.
   GeneralData.render(ping);
 
   // Show environment data.
   EnvironmentData.render(ping);
 
   // Show telemetry log.
   TelLog.render(ping);
@@ -1553,39 +1593,48 @@ function displayPingData(ping) {
   ChromeHangs.render(ping);
 
   // Show thread hang stats
   ThreadHangStats.render(ping);
 
   // Render Addon details.
   AddonDetails.render(ping);
 
+  // Select payload to render
+  let payloadSelect = document.getElementById("choose-payload");
+  let payloadOption = payloadSelect.selectedOptions.item(0);
+  let payloadIndex = payloadOption.getAttribute("value");
+
+  let payload = ping.payload;
+  if (payloadIndex > 0) {
+    payload = ping.payload.childPayloads[payloadIndex - 1];
+  }
+
   // Show simple measurements
-  let payload = ping.payload;
   let simpleMeasurements = sortStartupMilestones(payload.simpleMeasurements);
   let hasData = Object.keys(simpleMeasurements).length > 0;
   setHasData("simple-measurements-section", hasData);
   let simpleSection = document.getElementById("simple-measurements");
   removeAllChildNodes(simpleSection);
 
   if (hasData) {
     simpleSection.appendChild(KeyValueTable.render(simpleMeasurements,
                                                    keysHeader, valuesHeader));
   }
 
   LateWritesSingleton.renderLateWrites(payload.lateWrites);
 
   // Show basic system info gathered
-  hasData = Object.keys(payload.info).length > 0;
+  hasData = Object.keys(ping.payload.info).length > 0;
   setHasData("system-info-section", hasData);
   let infoSection = document.getElementById("system-info");
   removeAllChildNodes(infoSection);
 
   if (hasData) {
-    infoSection.appendChild(KeyValueTable.render(payload.info,
+    infoSection.appendChild(KeyValueTable.render(ping.payload.info,
                                                  keysHeader, valuesHeader));
   }
 
   // Show histogram data
   let hgramDiv = document.getElementById("histograms");
   removeAllChildNodes(hgramDiv);
 
   let histograms = payload.histograms;
--- a/toolkit/content/aboutTelemetry.xhtml
+++ b/toolkit/content/aboutTelemetry.xhtml
@@ -77,16 +77,27 @@
                 </td>
                 <td>
                     <select id="choose-ping-id">
                     </select>
                 </td>
             </tr>
           </table>
         </div>
+        <table>
+            <tr>
+                <th>&aboutTelemetry.payloadChoiceHeader;</th>
+            </tr>
+            <tr>
+                <td>
+                    <select id="choose-payload">
+                    </select>
+                </td>
+            </tr>
+        </table>
       </div>
     </header>
 
     <section id="general-data-section" class="data-section">
       <input type="checkbox" class="statebox"/>
       <h1 class="section-name">&aboutTelemetry.generalDataSection;</h1>
       <span class="toggle-caption">&aboutTelemetry.toggle;</span>
       <span class="empty-caption">&aboutTelemetry.emptySection;</span>
--- a/toolkit/locales/en-US/chrome/global/aboutTelemetry.dtd
+++ b/toolkit/locales/en-US/chrome/global/aboutTelemetry.dtd
@@ -130,8 +130,12 @@ Ping
 
 <!ENTITY aboutTelemetry.hideSymbols "
   Show raw data from hangs
 ">
 
 <!ENTITY aboutTelemetry.filterText "
   Filter (strings or /regexp/)
 ">
+
+<!ENTITY aboutTelemetry.payloadChoiceHeader "
+  Payload
+">
--- a/toolkit/locales/en-US/chrome/global/aboutTelemetry.properties
+++ b/toolkit/locales/en-US/chrome/global/aboutTelemetry.properties
@@ -64,8 +64,14 @@ valuesHeader = Value
 
 addonTableID = Add-on ID
 
 addonTableDetails = Details
 
 # Note to translators:
 # - The %1$S will be replaced with the name of an Add-on Provider (e.g. "XPI", "Plugin")
 addonProvider = %1$S Provider
+
+parentPayload = Parent Payload
+
+# Note to translators:
+# - The %1$s will be replaced with the number of the child payload (e.g. "1", "2")
+childPayload = Child Payload %1$s