Bug 1120408 - Show TelemetryLog in about:telemetry. r=felipe,gfritzsche

This commit is contained in:
Manraj Singh 2015-03-19 20:23:56 -03:00
parent cedfad6fdd
commit 9542cd2104
4 changed files with 76 additions and 0 deletions

View File

@ -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(
@ -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"),
@ -993,6 +1045,9 @@ function onLoad() {
// Show general data.
GeneralData.render();
// Show telemetry log.
TelLog.render();
// Show slow SQL stats
SlowSQL.render();

View File

@ -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>

View File

@ -16,6 +16,10 @@
General Data
">
<!ENTITY aboutTelemetry.telemetryLogSection "
Telemetry Log
">
<!ENTITY aboutTelemetry.slowSqlSection "
Slow SQL Statements
">

View File

@ -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