Bug 1120408 - Show TelemetryLog in about:telemetry. r=felipe,gfritzsche
authorManraj Singh <manrajsinghgrover@gmail.com>
Thu, 19 Mar 2015 20:23:56 -0300
changeset 251836 6f2e247fb7b7be87a825ebaa97b35126d5faf9d8
parent 251835 ad7b242dfaf79224da1436055855f635c99fd6fd
child 251837 91a05713580d29ce2024d8e6c690b6ced4af1ca6
push id1156
push userpbrosset@mozilla.com
push dateFri, 20 Mar 2015 16:00:24 +0000
reviewersfelipe, gfritzsche
bugs1120408
milestone39.0a1
Bug 1120408 - Show TelemetryLog in about:telemetry. r=felipe,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
@@ -7,16 +7,17 @@
 const Ci = Components.interfaces;
 const Cc = Components.classes;
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/TelemetryTimestamps.jsm");
 Cu.import("resource://gre/modules/TelemetryPing.jsm");
 Cu.import("resource://gre/modules/TelemetrySession.jsm");
+Cu.import("resource://gre/modules/TelemetryLog.jsm");
 
 const Telemetry = Services.telemetry;
 const bundle = Services.strings.createBundle(
   "chrome://global/locale/aboutTelemetry.properties");
 const brandBundle = Services.strings.createBundle(
   "chrome://branding/locale/brand.properties");
 
 // Maximum height of a histogram bar (in em for html, in chars for text)
@@ -147,16 +148,67 @@ let GeneralData = {
   appendColumn: function(aRowElement, aColType, aColText) {
     let colElement = document.createElement(aColType);
     let colTextElement = document.createTextNode(aColText);
     colElement.appendChild(colTextElement);
     aRowElement.appendChild(colElement);
   },
 };
 
+let TelLog = {
+  /**
+   * Renders the telemetry log
+   */
+  render: function() {
+    let entries =  TelemetryLog.entries();
+
+    if(entries.length == 0) {
+        return;
+    }
+    setHasData("telemetry-log-section", true);
+    let table = document.createElement("table");
+
+    let caption = document.createElement("caption");
+    let captionString = bundle.GetStringFromName("telemetryLogTitle");
+    caption.appendChild(document.createTextNode(captionString + "\n"));
+    table.appendChild(caption);
+
+    let headings = document.createElement("tr");
+    this.appendColumn(headings, "th", bundle.GetStringFromName("telemetryLogHeadingId") + "\t");
+    this.appendColumn(headings, "th", bundle.GetStringFromName("telemetryLogHeadingTimestamp") + "\t");
+    this.appendColumn(headings, "th", bundle.GetStringFromName("telemetryLogHeadingData") + "\t");
+    table.appendChild(headings);
+
+    for (let entry of entries) {
+        let row = document.createElement("tr");
+        for (let elem of entry) {
+            this.appendColumn(row, "td", elem + "\t");
+        }
+        table.appendChild(row);
+    }
+
+    let dataDiv = document.getElementById("telemetry-log");
+    dataDiv.appendChild(table);
+  },
+
+  /**
+   * Helper function for appending a column to the data table.
+   *
+   * @param aRowElement Parent row element
+   * @param aColType Column's tag name
+   * @param aColText Column contents
+   */
+  appendColumn: function(aRowElement, aColType, aColText) {
+    let colElement = document.createElement(aColType);
+    let colTextElement = document.createTextNode(aColText);
+    colElement.appendChild(colTextElement);
+    aRowElement.appendChild(colElement);
+  },
+};
+
 let SlowSQL = {
 
   slowSqlHits: bundle.GetStringFromName("slowSqlHits"),
 
   slowSqlAverage: bundle.GetStringFromName("slowSqlAverage"),
 
   slowSqlStatement: bundle.GetStringFromName("slowSqlStatement"),
 
@@ -988,16 +1040,19 @@ function onLoad() {
   setupPageHeader();
 
   // Set up event listeners
   setupListeners();
 
   // Show general data.
   GeneralData.render();
 
+  // Show telemetry log.
+  TelLog.render();
+
   // Show slow SQL stats
   SlowSQL.render();
 
   // Show chrome hang stacks
   ChromeHangs.render();
 
   // Show thread hang stats
   ThreadHangStats.render();
--- a/toolkit/content/aboutTelemetry.xhtml
+++ b/toolkit/content/aboutTelemetry.xhtml
@@ -39,16 +39,25 @@
       <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>
       <div id="general-data" class="data">
       </div>
     </section>
 
+    <section id="telemetry-log-section" class="data-section">
+      <input type="checkbox" class="statebox"/>
+      <h1 class="section-name">&aboutTelemetry.telemetryLogSection;</h1>
+      <span class="toggle-caption">&aboutTelemetry.toggle;</span>
+      <span class="empty-caption">&aboutTelemetry.emptySection;</span>
+      <div id="telemetry-log" class="data">
+      </div>
+    </section>
+
     <section id="slow-sql-section" class="data-section">
       <input type="checkbox" class="statebox"/>
       <h1 class="section-name">&aboutTelemetry.slowSqlSection;</h1>
       <span class="toggle-caption">&aboutTelemetry.toggle;</span>
       <span class="empty-caption">&aboutTelemetry.emptySection;</span>
       <div id="slow-sql-tables" class="data">
         <p id="sql-warning" class="hidden">&aboutTelemetry.fullSqlWarning;</p>
       </div>
--- a/toolkit/locales/en-US/chrome/global/aboutTelemetry.dtd
+++ b/toolkit/locales/en-US/chrome/global/aboutTelemetry.dtd
@@ -11,16 +11,20 @@
 <!ENTITY aboutTelemetry.telemetryDisabled "
   Telemetry is <span>disabled</span>.
 ">
 
 <!ENTITY aboutTelemetry.generalDataSection "
   General Data
 ">
 
+<!ENTITY aboutTelemetry.telemetryLogSection "
+  Telemetry Log
+">
+
 <!ENTITY aboutTelemetry.slowSqlSection "
   Slow SQL Statements
 ">
 
 <!ENTITY aboutTelemetry.chromeHangsSection "
   Browser Hangs
 ">
 
--- a/toolkit/locales/en-US/chrome/global/aboutTelemetry.properties
+++ b/toolkit/locales/en-US/chrome/global/aboutTelemetry.properties
@@ -8,16 +8,24 @@
 pageSubtitle = This page shows the information about performance, hardware, usage and customizations collected by Telemetry. This information is submitted to %1$S to help improve %2$S.
 
 generalDataTitle = General Data
 
 generalDataHeadingName = Name
 
 generalDataHeadingValue = Value
 
+telemetryLogTitle = Telemetry Log
+
+telemetryLogHeadingId = Id
+
+telemetryLogHeadingTimestamp = Timestamp
+
+telemetryLogHeadingData = Data
+
 slowSqlMain = Slow SQL Statements on Main Thread
 
 slowSqlOther = Slow SQL Statements on Helper Threads
 
 slowSqlHits = Hits
 
 slowSqlAverage = Avg. Time (ms)