Bug 1369049 - Moved code that checks for big pings after the ping is compressed. Had to update test_discardBigPings to send a 4MB ping due to the ping being compressed; r=chutten

MozReview-Commit-ID: DlCyF8BKL5Q

--HG--
extra : rebase_source : ce46b6150547f82517d55ad278e7bd54d9ae63d8
This commit is contained in:
Jason 2018-05-04 20:26:31 -04:00
Родитель ce614f2cb3
Коммит 1acb88189f
2 изменённых файлов: 10 добавлений и 10 удалений

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

@ -1211,13 +1211,18 @@ var TelemetrySendImpl = {
utf8Payload += converter.Finish();
Telemetry.getHistogramById("TELEMETRY_STRINGIFY").add(Utils.monotonicNow() - startTime);
let payloadStream = Cc["@mozilla.org/io/string-input-stream;1"]
.createInstance(Ci.nsIStringInputStream);
startTime = Utils.monotonicNow();
payloadStream.data = gzipCompressString(utf8Payload);
// Check the size and drop pings which are too big.
const pingSizeBytes = utf8Payload.length;
if (pingSizeBytes > TelemetryStorage.MAXIMUM_PING_SIZE) {
this._log.error("_doPing - submitted ping exceeds the size limit, size: " + pingSizeBytes);
const compressedPingSizeBytes = payloadStream.data.length;
if (compressedPingSizeBytes > TelemetryStorage.MAXIMUM_PING_SIZE) {
this._log.error("_doPing - submitted ping exceeds the size limit, size: " + compressedPingSizeBytes);
Telemetry.getHistogramById("TELEMETRY_PING_SIZE_EXCEEDED_SEND").add();
Telemetry.getHistogramById("TELEMETRY_DISCARDED_SEND_PINGS_SIZE_MB")
.add(Math.floor(pingSizeBytes / 1024 / 1024));
.add(Math.floor(compressedPingSizeBytes / 1024 / 1024));
// We don't need to call |request.abort()| as it was not sent yet.
this._pendingPingRequests.delete(id);
@ -1225,11 +1230,6 @@ var TelemetrySendImpl = {
return TelemetryStorage.removePendingPing(id);
}
let payloadStream = Cc["@mozilla.org/io/string-input-stream;1"]
.createInstance(Ci.nsIStringInputStream);
startTime = Utils.monotonicNow();
payloadStream.data = gzipCompressString(utf8Payload);
const compressedPingSizeKB = Math.floor(payloadStream.data.length / 1024);
Telemetry.getHistogramById("TELEMETRY_COMPRESS").add(Utils.monotonicNow() - startTime);
request.sendInputStream(payloadStream);

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

@ -335,7 +335,7 @@ add_task(async function test_discardBigPings() {
}
// Generate a 2MB string and create an oversized payload.
const OVERSIZED_PAYLOAD = {"data": generateRandomString(2 * 1024 * 1024)};
const OVERSIZED_PAYLOAD = {"data": generateRandomString(4 * 1024 * 1024)};
// Submit a ping of a normal size and check that we don't count it in the histogram.
await TelemetryController.submitExternalPing(TEST_PING_TYPE, { test: "test" });