Skip to content

Commit

Permalink
Bug 1120408 - Show TelemetryLog in about:telemetry. r=felipe,gfritzsche
Browse files Browse the repository at this point in the history
  • Loading branch information
manrajgrover committed Mar 19, 2015
1 parent ec5d545 commit 2216b53
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
55 changes: 55 additions & 0 deletions toolkit/content/aboutTelemetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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(
Expand Down Expand Up @@ -152,6 +153,57 @@ let GeneralData = {
},
};

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"),
Expand Down Expand Up @@ -993,6 +1045,9 @@ function onLoad() {
// Show general data.
GeneralData.render();

// Show telemetry log.
TelLog.render();

// Show slow SQL stats
SlowSQL.render();

Expand Down
9 changes: 9 additions & 0 deletions toolkit/content/aboutTelemetry.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
</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>
Expand Down
4 changes: 4 additions & 0 deletions toolkit/locales/en-US/chrome/global/aboutTelemetry.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
General Data
">

<!ENTITY aboutTelemetry.telemetryLogSection "
Telemetry Log
">

<!ENTITY aboutTelemetry.slowSqlSection "
Slow SQL Statements
">
Expand Down
8 changes: 8 additions & 0 deletions toolkit/locales/en-US/chrome/global/aboutTelemetry.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ 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
Expand Down

0 comments on commit 2216b53

Please sign in to comment.