Bug 1127918 - Record & submit the appropriate telemetry datasets when FHR is enabled. r=vladan

This commit is contained in:
Alessio Placitelli 2015-03-09 00:53:00 +01:00
Родитель d19436f3f5
Коммит 81b3e42564
2 изменённых файлов: 99 добавлений и 24 удалений

Просмотреть файл

@ -838,16 +838,14 @@ let Impl = {
Cu.import("resource://gre/modules/TelemetryTimestamps.jsm", o);
appTimestamps = o.TelemetryTimestamps.get();
} catch (ex) {}
try {
if (!IS_CONTENT_PROCESS) {
// Only submit this if the extended set is enabled.
if (!IS_CONTENT_PROCESS && Telemetry.canRecordExtended) {
try {
ret.addonManager = AddonManagerPrivate.getSimpleMeasures();
}
} catch (ex) {}
try {
if (!IS_CONTENT_PROCESS) {
ret.UITelemetry = UITelemetry.getSimpleMeasures();
}
} catch (ex) {}
} catch (ex) {}
}
if (si.process) {
for each (let field in Object.keys(si)) {
@ -984,11 +982,20 @@ let Impl = {
return retgram;
},
/**
* Get the type of the dataset that needs to be collected, based on the preferences.
* @return {Integer} A value from nsITelemetry.DATASET_*.
*/
getDatasetType: function() {
return Telemetry.canRecordExtended ? Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN
: Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT;
},
getHistograms: function getHistograms(subsession, clearSubsession) {
this._log.trace("getHistograms - subsession: " + subsession + ", clearSubsession: " + clearSubsession);
let registered =
Telemetry.registeredHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, []);
Telemetry.registeredHistograms(this.getDatasetType(), []);
let hls = subsession ? Telemetry.snapshotSubsessionHistograms(clearSubsession)
: Telemetry.histogramSnapshots;
let ret = {};
@ -1027,7 +1034,7 @@ let Impl = {
this._log.trace("getKeyedHistograms - subsession: " + subsession + ", clearSubsession: " + clearSubsession);
let registered =
Telemetry.registeredKeyedHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, []);
Telemetry.registeredKeyedHistograms(this.getDatasetType(), []);
let ret = {};
for (let id of registered) {
@ -1115,6 +1122,11 @@ let Impl = {
* Pull values from about:memory into corresponding histograms
*/
gatherMemory: function gatherMemory() {
if (!Telemetry.canRecordExtended) {
this._log.trace("gatherMemory - Extended data recording disabled, skipping.");
return;
}
this._log.trace("gatherMemory");
let mgr;
@ -1242,7 +1254,7 @@ let Impl = {
this._log.trace("gatherStartupHistograms");
let info =
Telemetry.registeredHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, []);
Telemetry.registeredHistograms(this.getDatasetType(), []);
let snapshots = Telemetry.histogramSnapshots;
for (let name of info) {
// Only duplicate histograms with actual data.
@ -1274,28 +1286,36 @@ let Impl = {
simpleMeasurements: simpleMeasurements,
histograms: this.getHistograms(isSubsession, clearSubsession),
keyedHistograms: this.getKeyedHistograms(isSubsession, clearSubsession),
chromeHangs: Telemetry.chromeHangs,
threadHangStats: this.getThreadHangStats(Telemetry.threadHangStats),
log: TelemetryLog.entries(),
};
// Add extended set measurements common to chrome & content processes
if (Telemetry.canRecordExtended) {
payloadObj.chromeHangs = Telemetry.chromeHangs;
payloadObj.threadHangStats = this.getThreadHangStats(Telemetry.threadHangStats);
payloadObj.log = TelemetryLog.entries();
}
if (IS_CONTENT_PROCESS) {
return payloadObj;
}
// Additional payload for chrome process.
payloadObj.info = info;
payloadObj.slowSQL = Telemetry.slowSQL;
payloadObj.fileIOReports = Telemetry.fileIOReports;
payloadObj.lateWrites = Telemetry.lateWrites;
payloadObj.addonHistograms = this.getAddonHistograms();
payloadObj.addonDetails = AddonManagerPrivate.getTelemetryDetails();
payloadObj.UIMeasurements = UITelemetry.getUIMeasurements();
if (Object.keys(this._slowSQLStartup).length != 0 &&
(Object.keys(this._slowSQLStartup.mainThread).length ||
Object.keys(this._slowSQLStartup.otherThreads).length)) {
payloadObj.slowSQLStartup = this._slowSQLStartup;
// Add extended set measurements for chrome process.
if (Telemetry.canRecordExtended) {
payloadObj.slowSQL = Telemetry.slowSQL;
payloadObj.fileIOReports = Telemetry.fileIOReports;
payloadObj.lateWrites = Telemetry.lateWrites;
payloadObj.addonHistograms = this.getAddonHistograms();
payloadObj.addonDetails = AddonManagerPrivate.getTelemetryDetails();
payloadObj.UIMeasurements = UITelemetry.getUIMeasurements();
if (Object.keys(this._slowSQLStartup).length != 0 &&
(Object.keys(this._slowSQLStartup.mainThread).length ||
Object.keys(this._slowSQLStartup.otherThreads).length)) {
payloadObj.slowSQLStartup = this._slowSQLStartup;
}
}
if (this._childTelemetry.length) {

Просмотреть файл

@ -1503,6 +1503,61 @@ add_task(function* test_schedulerNothingDue() {
yield TelemetrySession.shutdown();
});
add_task(function* test_pingExtendedStats() {
const EXTENDED_PAYLOAD_FIELDS = [
"chromeHangs", "threadHangStats", "log", "slowSQL", "fileIOReports", "lateWrites",
"addonHistograms", "addonDetails", "UIMeasurements",
];
// Disable sending extended statistics.
Telemetry.canRecordExtended = false;
gRequestIterator = Iterator(new Request());
yield TelemetrySession.reset();
yield sendPing();
let request = yield gRequestIterator.next();
let ping = decodeRequestPayload(request);
checkPingFormat(ping, PING_TYPE_MAIN, true, true);
// Check that the payload does not contain extended statistics fields.
for (let f in EXTENDED_PAYLOAD_FIELDS) {
Assert.ok(!(EXTENDED_PAYLOAD_FIELDS[f] in ping.payload),
EXTENDED_PAYLOAD_FIELDS[f] + " must not be in the payload if the extended set is off.");
}
// We check this one separately so that we can reuse EXTENDED_PAYLOAD_FIELDS below, since
// slowSQLStartup might not be there.
Assert.ok(!("slowSQLStartup" in ping.payload),
"slowSQLStartup must not be sent if the extended set is off");
Assert.ok(!("addonManager" in ping.payload.simpleMeasurements),
"addonManager must not be sent if the extended set is off.");
Assert.ok(!("UITelemetry" in ping.payload.simpleMeasurements),
"UITelemetry must not be sent if the extended set is off.");
// Restore the preference.
Telemetry.canRecordExtended = true;
// Send a new ping that should contain the extended data.
yield TelemetrySession.reset();
yield sendPing();
request = yield gRequestIterator.next();
ping = decodeRequestPayload(request);
checkPingFormat(ping, PING_TYPE_MAIN, true, true);
// Check that the payload now contains extended statistics fields.
for (let f in EXTENDED_PAYLOAD_FIELDS) {
Assert.ok(EXTENDED_PAYLOAD_FIELDS[f] in ping.payload,
EXTENDED_PAYLOAD_FIELDS[f] + " must be in the payload if the extended set is on.");
}
Assert.ok("addonManager" in ping.payload.simpleMeasurements,
"addonManager must be sent if the extended set is on.");
Assert.ok("UITelemetry" in ping.payload.simpleMeasurements,
"UITelemetry must be sent if the extended set is on.");
});
add_task(function* stopServer(){
gHttpServer.stop(do_test_finished);
});