From 10540b016989c1d45515d3c3c79c36dc73e152d6 Mon Sep 17 00:00:00 2001 From: Chris H-C Date: Wed, 29 Jun 2016 15:46:22 -0400 Subject: [PATCH 05/10] bug 1218576 - Move aggregated child telemetry to processes.content r?gfritzsche Take the opportunity presented through changing child telemetry accumulation to bring the ping form closer to the ideas expressed in bug 1281795. childPayloads still exists, but without histograms or keyedHistograms which are now at root.processes.content.{keyedH|h}istograms. This will require coordinated changes in the aggregator and moztelemetry libraries. MozReview-Commit-ID: AqG2jmBBC2W --- toolkit/components/telemetry/TelemetrySession.jsm | 90 +++++++++++++++-------- 1 file changed, 58 insertions(+), 32 deletions(-) diff --git a/toolkit/components/telemetry/TelemetrySession.jsm b/toolkit/components/telemetry/TelemetrySession.jsm index 55c6fe9..d946196 100644 --- a/toolkit/components/telemetry/TelemetrySession.jsm +++ b/toolkit/components/telemetry/TelemetrySession.jsm @@ -41,6 +41,11 @@ const REASON_TEST_PING = "test-ping"; const REASON_ENVIRONMENT_CHANGE = "environment-change"; const REASON_SHUTDOWN = "shutdown"; +const HISTOGRAM_SUFFIXES = { + PARENT: "", + CONTENT: "#content", +} + const ENVIRONMENT_CHANGE_LISTENER = "TelemetrySession::onEnvironmentChange"; const MS_IN_ONE_HOUR = 60 * 60 * 1000; @@ -876,23 +881,28 @@ var Impl = { }, getHistograms: function getHistograms(subsession, clearSubsession) { - this._log.trace("getHistograms - subsession: " + subsession + ", clearSubsession: " + clearSubsession); + this._log.trace("getHistograms - subsession: " + subsession + + ", clearSubsession: " + clearSubsession); let registered = Telemetry.registeredHistograms(this.getDatasetType(), []); + if (this._testing == false) { + // Omit telemetry test histograms outside of tests. + registered = registered.filter(n => !n.startsWith("TELEMETRY_TEST_")); + } + registered = registered.concat(registered.map(n => "STARTUP_" + n)); + let hls = subsession ? Telemetry.snapshotSubsessionHistograms(clearSubsession) : Telemetry.histogramSnapshots; let ret = {}; for (let name of registered) { - for (let n of [name, "STARTUP_" + name]) { - if (n in hls) { - // Omit telemetry test histograms outside of tests. - if (n.startsWith('TELEMETRY_TEST_') && this._testing == false) { - this._log.trace("getHistograms - Skipping test histogram: " + n); - } else { - ret[n] = this.packHistogram(hls[n]); + for (let suffix of Object.values(HISTOGRAM_SUFFIXES)) { + if (name + suffix in hls) { + if (!(suffix in ret)) { + ret[suffix] = {}; } + ret[suffix][name] = this.packHistogram(hls[name + suffix]); } } } @@ -920,36 +930,41 @@ var Impl = { }, getKeyedHistograms: function(subsession, clearSubsession) { - this._log.trace("getKeyedHistograms - subsession: " + subsession + ", clearSubsession: " + clearSubsession); + this._log.trace("getKeyedHistograms - subsession: " + subsession + + ", clearSubsession: " + clearSubsession); let registered = Telemetry.registeredKeyedHistograms(this.getDatasetType(), []); + if (this._testing == false) { + // Omit telemetry test histograms outside of tests. + registered = registered.filter(id => !id.startsWith("TELEMETRY_TEST_")); + } let ret = {}; for (let id of registered) { - // Omit telemetry test histograms outside of tests. - if (id.startsWith('TELEMETRY_TEST_') && this._testing == false) { - this._log.trace("getKeyedHistograms - Skipping test histogram: " + id); - continue; - } - let keyed = Telemetry.getKeyedHistogramById(id); - let snapshot = null; - if (subsession) { - snapshot = clearSubsession ? keyed.snapshotSubsessionAndClear() - : keyed.subsessionSnapshot(); - } else { - snapshot = keyed.snapshot(); - } + for (let suffix of Object.values(HISTOGRAM_SUFFIXES)) { + let keyed = Telemetry.getKeyedHistogramById(id + suffix); + let snapshot = null; + if (subsession) { + snapshot = clearSubsession ? keyed.snapshotSubsessionAndClear() + : keyed.subsessionSnapshot(); + } else { + snapshot = keyed.snapshot(); + } - let keys = Object.keys(snapshot); - if (keys.length == 0) { - // Skip empty keyed histogram. - continue; - } + let keys = Object.keys(snapshot); + if (keys.length == 0) { + // Skip empty keyed histogram. + continue; + } - ret[id] = {}; - for (let key of keys) { - ret[id][key] = this.packHistogram(snapshot[key]); + if (!(suffix in ret)) { + ret[suffix] = {}; + } + ret[suffix][id] = {}; + for (let key of keys) { + ret[suffix][id][key] = this.packHistogram(snapshot[key]); + } } } @@ -1248,11 +1263,22 @@ var Impl = { let payloadObj = { ver: PAYLOAD_VERSION, simpleMeasurements: simpleMeasurements, - histograms: protect(() => this.getHistograms(isSubsession, clearSubsession)), - keyedHistograms: protect(() => this.getKeyedHistograms(isSubsession, clearSubsession)), scalars: protect(() => this.getScalars(isSubsession, clearSubsession)), }; + if (!Utils.isContentProcess) { + let histograms = protect(() => this.getHistograms(isSubsession, clearSubsession)); + let keyedHistograms = protect(() => this.getKeyedHistograms(isSubsession, clearSubsession)); + payloadObj.histograms = histograms[HISTOGRAM_SUFFIXES.PARENT]; + payloadObj.keyedHistograms = keyedHistograms[HISTOGRAM_SUFFIXES.PARENT]; + payloadObj.processes = { + content: { + histograms: histograms[HISTOGRAM_SUFFIXES.CONTENT], + keyedHistograms: keyedHistograms[HISTOGRAM_SUFFIXES.CONTENT], + }, + }; + } + // Add extended set measurements common to chrome & content processes if (Telemetry.canRecordExtended) { payloadObj.chromeHangs = protect(() => Telemetry.chromeHangs); -- 2.7.4.windows.1