From 9ab233744bae6fa3041df86591d2960695be3598 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Mon, 13 Feb 2012 15:04:21 -0500 Subject: [PATCH] Bug 720456 - Include more startup-relevant information in telemetry pings. r=taras --- toolkit/components/telemetry/TelemetryPing.js | 29 +++++++++++++++---- .../tests/unit/test_TelemetryPing.js | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/toolkit/components/telemetry/TelemetryPing.js b/toolkit/components/telemetry/TelemetryPing.js index ea3ca0179a10..405a15b96882 100644 --- a/toolkit/components/telemetry/TelemetryPing.js +++ b/toolkit/components/telemetry/TelemetryPing.js @@ -182,6 +182,9 @@ TelemetryPing.prototype = { // Generate a unique id once per session so the server can cope with // duplicate submissions. _uuid: generateUUID(), + // Regex that matches histograms we carea bout during startup. + _startupHistogramRegex: /SQLITE|HTTP|SPDY|CACHE|DNS/, + _slowSQLStartup: {}, /** * Returns a set of histograms that can be converted into JSON @@ -381,17 +384,28 @@ TelemetryPing.prototype = { this.addValue(mr.path, id, val); } }, + + /** + * Return true if we're interested in having a STARTUP_* histogram for + * the given histogram name. + */ + isInterestingStartupHistogram: function isInterestingStartupHistogram(name) { + return this._startupHistogramRegex.test(name); + }, /** - * Make a copy of sqlite histograms on startup + * Make a copy of interesting histograms at startup. */ - gatherStartupSqlite: function gatherStartupSqlite() { + gatherStartupInformation: function gatherStartupInformation() { let info = Telemetry.registeredHistograms; - let sqlite_re = /SQLITE/; + let snapshots = Telemetry.histogramSnapshots; for (let name in info) { - if (sqlite_re.test(name)) + // Only duplicate histograms with actual data. + if (this.isInterestingStartupHistogram(name) && name in snapshots) { Telemetry.histogramFrom("STARTUP_" + name, name); + } } + this._slowSQLStartup = Telemetry.slowSQL; }, getSessionPayloadAndSlug: function getSessionPayloadAndSlug(reason) { @@ -404,6 +418,10 @@ TelemetryPing.prototype = { histograms: this.getHistograms(), slowSQL: Telemetry.slowSQL }; + if (Object.keys(this._slowSQLStartup.mainThread).length + || Object.keys(this._slowSQLStartup.otherThreads).length) { + payloadObj.slowSQLStartup = this._slowSQLStartup; + } return { slug: slug, payload: JSON.stringify(payloadObj) }; }, @@ -546,7 +564,7 @@ TelemetryPing.prototype = { } break; case "sessionstore-windows-restored": - this.gatherStartupSqlite(); + this.gatherStartupInformation(); break; case "idle-daily": // Enqueue to main-thread, otherwise components may be inited by the @@ -561,6 +579,7 @@ TelemetryPing.prototype = { break; case "get-payload": this.gatherMemory(); + this.gatherStartupInformation(); let data = this.getSessionPayloadAndSlug("gather-payload"); aSubject.QueryInterface(Ci.nsISupportsString).data = data.payload; diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js index 3dd406ebec37..f85a86099966 100644 --- a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js @@ -29,8 +29,8 @@ var gFinished = false; function telemetry_ping () { const TelemetryPing = Cc["@mozilla.org/base/telemetry-ping;1"].getService(Ci.nsIObserver); - TelemetryPing.observe(null, "test-ping", SERVER); TelemetryPing.observe(null, "sessionstore-windows-restored", null); + TelemetryPing.observe(null, "test-ping", SERVER); } function nonexistentServerObserver(aSubject, aTopic, aData) {