зеркало из https://github.com/mozilla/gecko-dev.git
bug 1319026 - Put an arbitrary upper-limit on TelemetryLog r=gfritzsche
To protect against pathalogically-bad cases of log abuse, limit TelemetryLog to the first 1000 entries. MozReview-Commit-ID: yoTFVS1VdQ --HG-- extra : rebase_source : 04fae88fe619bb635b20f84549698348481825ea
This commit is contained in:
Родитель
cc69375ea9
Коммит
9441f885dd
|
@ -8,10 +8,16 @@ const Cc = Components.classes;
|
|||
const Ci = Components.interfaces;
|
||||
|
||||
const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
|
||||
|
||||
const LOG_ENTRY_MAX_COUNT = 1000;
|
||||
|
||||
var gLogEntries = [];
|
||||
|
||||
this.TelemetryLog = Object.freeze({
|
||||
log(id, data) {
|
||||
if (gLogEntries.length >= LOG_ENTRY_MAX_COUNT) {
|
||||
return;
|
||||
}
|
||||
id = String(id);
|
||||
var ts;
|
||||
try {
|
||||
|
|
|
@ -16,7 +16,7 @@ The current data collection possibilities include:
|
|||
* :doc:`histograms` can efficiently record multiple data points
|
||||
* ``environment`` data records information about the system and settings a session occurs in
|
||||
* :doc:`events` can record richer data on individual occurences of specific actions
|
||||
* ``TelemetryLog`` allows collecting ordered event entries (note: this does not have supporting analysis tools)
|
||||
* ``TelemetryLog`` allows collecting ordered event entries up to a limit of 1000 entries (note: this does not have supporting analysis tools)
|
||||
* :doc:`measuring elapsed time <measuring-time>`
|
||||
* :doc:`custom pings <custom-pings>`
|
||||
* :doc:`stack capture <stack-capture>` allow recording application call stacks
|
||||
|
|
|
@ -7,6 +7,8 @@ Cu.import("resource://gre/modules/TelemetrySession.jsm", this);
|
|||
const TEST_PREFIX = "TEST-";
|
||||
const TEST_REGEX = new RegExp("^" + TEST_PREFIX);
|
||||
|
||||
const LOG_ENTRY_MAX_COUNT = 1000;
|
||||
|
||||
function check_event(event, id, data) {
|
||||
do_print("Checking message " + id);
|
||||
do_check_eq(event[0], id);
|
||||
|
@ -45,5 +47,14 @@ add_task(function* () {
|
|||
do_check_true(log[0][1] <= log[1][1]);
|
||||
do_check_true(log[1][1] <= log[2][1]);
|
||||
|
||||
// Test that we limit the overall length of the log, and that pushing
|
||||
// it over the limit keeps the older events.
|
||||
for (let i = 0; i < LOG_ENTRY_MAX_COUNT + 1; i++) {
|
||||
TelemetryLog.log(TEST_PREFIX + "to_tha_limit");
|
||||
}
|
||||
log = TelemetrySession.getPayload().log;
|
||||
do_check_eq(log.length, LOG_ENTRY_MAX_COUNT);
|
||||
check_event(log[0], TEST_PREFIX + "1", ["val", "123", "undefined"]);
|
||||
|
||||
yield TelemetryController.testShutdown();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче