Bug 1505991 - Add new preference to disable ping throttling r=Dexter a=RyanVM
authorJan-Erik Rediger <jrediger@mozilla.com>
Thu, 13 Dec 2018 17:26:41 +0000
changeset 506222 34ce66233646020c044a3229ec905c236556ed81
parent 506221 d9d17041ca841fc9b80dc40eb926e376fd58a903
child 506223 e72979e80a1c63f5fc1e78c4619123edf0295dfa
push id10335
push usercsabou@mozilla.com
push dateFri, 14 Dec 2018 21:06:18 +0000
treeherdermozilla-beta@2c85064c240c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersDexter, RyanVM
bugs1505991
milestone65.0
Bug 1505991 - Add new preference to disable ping throttling r=Dexter a=RyanVM Marionette tests have a hard time properly overwriting the module's Policies that handle this in xpcshell tests currently. A preference on the other hand can be easily set from the outside, is persistent across restarts of the test instance and easily checked. Differential Revision: https://phabricator.services.mozilla.com/D14458
toolkit/components/telemetry/app/TelemetrySend.jsm
toolkit/components/telemetry/app/TelemetryUtils.jsm
toolkit/components/telemetry/docs/internals/preferences.rst
--- a/toolkit/components/telemetry/app/TelemetrySend.jsm
+++ b/toolkit/components/telemetry/app/TelemetrySend.jsm
@@ -541,22 +541,28 @@ var SendScheduler = {
    * This helper calculates the next time that we can send pings at.
    * Currently this mostly redistributes ping sends from midnight until one hour after
    * to avoid submission spikes around local midnight for daily pings.
    *
    * @param now Date The current time.
    * @return Number The next time (ms from UNIX epoch) when we can send pings.
    */
   _getNextPingSendTime(now) {
-    // 1. First we check if the time is between 0am and 1am. If it's not, we send
+    // 1. First we check if the pref is set to skip any delay and send immediately.
+    // 2. Next we check if the time is between 0am and 1am. If it's not, we send
     // immediately.
-    // 2. If we confirmed the time is indeed between 0am and 1am in step 1, we disallow
+    // 3. If we confirmed the time is indeed between 0am and 1am in step 1, we disallow
     // sending before (midnight + fuzzing delay), which is a random time between 0am-1am
     // (decided at startup).
 
+    let disableFuzzingDelay = Services.prefs.getBoolPref(TelemetryUtils.Preferences.DisableFuzzingDelay, false);
+    if (disableFuzzingDelay) {
+      return now.getTime();
+    }
+
     const midnight = Utils.truncateToDays(now);
     // Don't delay pings if we are not within the fuzzing interval.
     if ((now.getTime() - midnight.getTime()) > MIDNIGHT_FUZZING_INTERVAL_MS) {
       return now.getTime();
     }
 
     // Delay ping send if we are within the midnight fuzzing range.
     // We spread those ping sends out between |midnight| and |midnight + midnightPingFuzzingDelay|.
--- a/toolkit/components/telemetry/app/TelemetryUtils.jsm
+++ b/toolkit/components/telemetry/app/TelemetryUtils.jsm
@@ -26,16 +26,17 @@ const IS_CONTENT_PROCESS = (function() {
   return runtime.processType == Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT;
 })();
 
 var TelemetryUtils = {
   Preferences: Object.freeze({
     // General Preferences
     ArchiveEnabled: "toolkit.telemetry.archive.enabled",
     CachedClientId: "toolkit.telemetry.cachedClientID",
+    DisableFuzzingDelay: "toolkit.telemetry.testing.disableFuzzingDelay",
     FirstRun: "toolkit.telemetry.reportingpolicy.firstRun",
     FirstShutdownPingEnabled: "toolkit.telemetry.firstShutdownPing.enabled",
     HealthPingEnabled: "toolkit.telemetry.healthping.enabled",
     HybridContentEnabled: "toolkit.telemetry.hybridContent.enabled",
     IPCBatchTimeout: "toolkit.telemetry.ipcBatchTimeout",
     OverrideOfficialCheck: "toolkit.telemetry.send.overrideOfficialCheck",
     OverridePreRelease: "toolkit.telemetry.testing.overridePreRelease",
     OverrideUpdateChannel: "toolkit.telemetry.overrideUpdateChannel",
--- a/toolkit/components/telemetry/docs/internals/preferences.rst
+++ b/toolkit/components/telemetry/docs/internals/preferences.rst
@@ -267,8 +267,12 @@ The following prefs are for testing purp
 
 ``toolkit.telemetry.untrustedModulesPing.frequency``
 
   Interval, in seconds, between "untrustedModules" ping transmissions.
 
 ``toolkit.telemetry.healthping.enabled``
 
   If false, sending health pings is disabled. Defaults to true.
+
+``toolkit.telemetry.testing.disableFuzzingDelay``
+
+  If true, ping sending is not delayed when sending between 0am and 1am local time.