Bug 860094 - Remove saving of last payload to disk; r=rnewman

This commit is contained in:
Gregory Szorc 2013-05-01 09:55:30 -07:00
parent 61cf51e9b8
commit 52009ff5cb
3 changed files with 10 additions and 92 deletions

View File

@ -47,7 +47,6 @@ const TELEMETRY_GENERATE_PAYLOAD = "HEALTHREPORT_GENERATE_JSON_PAYLOAD_MS";
const TELEMETRY_JSON_PAYLOAD_SERIALIZE = "HEALTHREPORT_JSON_PAYLOAD_SERIALIZE_MS";
const TELEMETRY_PAYLOAD_SIZE_UNCOMPRESSED = "HEALTHREPORT_PAYLOAD_UNCOMPRESSED_BYTES";
const TELEMETRY_PAYLOAD_SIZE_COMPRESSED = "HEALTHREPORT_PAYLOAD_COMPRESSED_BYTES";
const TELEMETRY_SAVE_LAST_PAYLOAD = "HEALTHREPORT_SAVE_LAST_PAYLOAD_MS";
const TELEMETRY_UPLOAD = "HEALTHREPORT_UPLOAD_MS";
const TELEMETRY_SHUTDOWN_DELAY = "HEALTHREPORT_SHUTDOWN_DELAY_MS";
const TELEMETRY_COLLECT_CONSTANT = "HEALTHREPORT_COLLECT_CONSTANT_DATA_MS";
@ -103,9 +102,15 @@ function AbstractHealthReporter(branch, policy, sessionRecorder) {
TelemetryStopwatch.start(this._initHistogram, this);
this._ensureDirectoryExists(this._stateDir)
.then(this._onStateDirCreated.bind(this),
this._onInitError.bind(this));
// As soon as we could have storage, we need to register cleanup or
// else bad things (like hangs) happen on shutdown.
Services.obs.addObserver(this, "quit-application", false);
Services.obs.addObserver(this, "profile-before-change", false);
this._storageInProgress = true;
TelemetryStopwatch.start(this._dbOpenHistogram, this);
Metrics.Storage(this._dbName).then(this._onStorageCreated.bind(this),
this._onInitError.bind(this));
}
AbstractHealthReporter.prototype = Object.freeze({
@ -141,18 +146,6 @@ AbstractHealthReporter.prototype = Object.freeze({
// useful error message.
},
_onStateDirCreated: function () {
// As soon as we have could storage, we need to register cleanup or
// else bad things happen on shutdown.
Services.obs.addObserver(this, "quit-application", false);
Services.obs.addObserver(this, "profile-before-change", false);
this._storageInProgress = true;
TelemetryStopwatch.start(this._dbOpenHistogram, this);
Metrics.Storage(this._dbName).then(this._onStorageCreated.bind(this),
this._onInitError.bind(this));
},
// Called when storage has been opened.
_onStorageCreated: function (storage) {
TelemetryStopwatch.finish(this._dbOpenHistogram, this);
@ -814,49 +807,6 @@ AbstractHealthReporter.prototype = Object.freeze({
return deferred.promise;
},
get _lastPayloadPath() {
return OS.Path.join(this._stateDir, "lastpayload.json");
},
_saveLastPayload: function (payload) {
let path = this._lastPayloadPath;
let pathTmp = path + ".tmp";
let encoder = new TextEncoder();
let buffer = encoder.encode(payload);
return OS.File.writeAtomic(path, buffer, {tmpPath: pathTmp});
},
/**
* Obtain the last uploaded payload.
*
* The promise is resolved to a JSON-decoded object on success. The promise
* is rejected if the last uploaded payload could not be found or there was
* an error reading or parsing it.
*
* This reads the last payload from disk. If you are looking for a
* current snapshot of the data, see `getJSONPayload` and
* `collectAndObtainJSONPayload`.
*
* @return Promise<object>
*/
getLastPayload: function () {
let path = this._lastPayloadPath;
return OS.File.read(path).then(
function onData(buffer) {
let decoder = new TextDecoder();
let json = JSON.parse(decoder.decode(buffer));
return CommonUtils.laterTickResolvingPromise(json);
},
function onError(error) {
return Promise.reject(error);
}
);
},
_now: function _now() {
return new Date();
},
@ -1233,15 +1183,6 @@ HealthReporter.prototype = Object.freeze({
let histogram = Services.telemetry.getHistogramById(TELEMETRY_PAYLOAD_SIZE_UNCOMPRESSED);
histogram.add(payload.length);
TelemetryStopwatch.start(TELEMETRY_SAVE_LAST_PAYLOAD, this);
try {
yield this._saveLastPayload(payload);
TelemetryStopwatch.finish(TELEMETRY_SAVE_LAST_PAYLOAD, this);
} catch (ex) {
TelemetryStopwatch.cancel(TELEMETRY_SAVE_LAST_PAYLOAD, this);
throw ex;
}
let hrProvider = this.getProvider("org.mozilla.healthreport");
if (hrProvider) {
let event = this.lastSubmitID ? "continuationUploadAttempt"

View File

@ -598,7 +598,7 @@ add_task(function test_data_submission_success() {
do_check_true(reporter.haveRemoteData());
// Ensure data from providers made it to payload.
let o = yield reporter.getLastPayload();
let o = yield reporter.getJSONPayload(true);
do_check_true("DummyProvider.DummyMeasurement" in o.data.last);
do_check_true("DummyConstantProvider.DummyMeasurement" in o.data.last);
@ -704,22 +704,6 @@ add_task(function test_policy_accept_reject() {
}
});
add_task(function test_upload_save_payload() {
let [reporter, server] = yield getReporterAndServer("upload_save_payload");
try {
let deferred = Promise.defer();
let request = new DataSubmissionRequest(deferred, new Date(), false);
yield reporter._uploadData(request);
let json = yield reporter.getLastPayload();
do_check_true("thisPingDate" in json);
} finally {
reporter._shutdown();
yield shutdownServer(server);
}
});
add_task(function test_error_message_scrubbing() {
let reporter = yield getReporter("error_message_scrubbing");

View File

@ -3109,13 +3109,6 @@
"extended_statistics_ok": true,
"description": "Time (ms) it takes to upload the Health Report payload."
},
"HEALTHREPORT_SAVE_LAST_PAYLOAD_MS": {
"kind": "exponential",
"high": "10000",
"n_buckets": 10,
"extended_statistics_ok": true,
"description": "Time (ms) it takes to persist the last submitted Health Report payload to disk."
},
"HEALTHREPORT_COLLECT_CONSTANT_DATA_MS": {
"kind": "exponential",
"high": "20000",