Bug 1369844 - Add switchboard experiment for background telemetry processing r=nalexander
authorGrigory Kruglov <gkruglov@mozilla.com>
Thu, 08 Jun 2017 16:46:53 -0400
changeset 411227 a43b9bebbc130260a86de84b06d0cf9f1add6796
parent 411226 bbabea85e0aad084a64e2d0b4ca3aa1ace4fda5b
child 411228 0dd4c63082dd9eaf9d0800a34eb575e05c8627fc
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1369844
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1369844 - Add switchboard experiment for background telemetry processing r=nalexander Intended use is a "kill-switch" for processing/upload of background telemetry. MozReview-Commit-ID: CXhQtkxljAy
mobile/android/base/java/org/mozilla/gecko/Experiments.java
mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryBackgroundReceiver.java
--- a/mobile/android/base/java/org/mozilla/gecko/Experiments.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Experiments.java
@@ -72,16 +72,19 @@ public class Experiments {
     public static final String COMPACT_TABS = "compact-tabs";
 
     // Enable full bookmark management(full-page dialog, bookmark/folder modification, etc.)
     public static final String FULL_BOOKMARK_MANAGEMENT = "full-bookmark-management";
 
     // Enable Leanplum SDK
     public static final String LEANPLUM = "leanplum-start";
 
+    // Enable processing of background telemetry.
+    public static final String ENABLE_PROCESSING_BACKGROUND_TELEMETRY = "process-background-telemetry";
+
     /**
      * Returns if a user is in certain local experiment.
      * @param experiment Name of experiment to look up
      * @return returns value for experiment or false if experiment does not exist.
      */
     public static boolean isInExperimentLocal(Context context, String experiment) {
         if (SwitchBoard.isInBucket(context, 0, 20)) {
             return Experiments.ONBOARDING3_A.equals(experiment);
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryBackgroundReceiver.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryBackgroundReceiver.java
@@ -12,16 +12,18 @@ import android.content.SharedPreferences
 import android.os.Bundle;
 import android.os.Parcelable;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
 import android.support.v4.content.LocalBroadcastManager;
 import android.util.Log;
 
 import org.mozilla.gecko.AppConstants;
+import org.mozilla.gecko.Experiments;
+import org.mozilla.gecko.switchboard.SwitchBoard;
 import org.mozilla.gecko.sync.telemetry.TelemetryContract;
 import org.mozilla.gecko.telemetry.pingbuilders.TelemetrySyncEventPingBuilder;
 import org.mozilla.gecko.telemetry.pingbuilders.TelemetrySyncPingBuilder;
 import org.mozilla.gecko.telemetry.pingbuilders.TelemetrySyncPingBundleBuilder;
 import org.mozilla.gecko.telemetry.schedulers.TelemetryUploadAllPingsImmediatelyScheduler;
 import org.mozilla.gecko.telemetry.schedulers.TelemetryUploadScheduler;
 import org.mozilla.gecko.telemetry.stores.TelemetryJSONFilePingStore;
 import org.mozilla.gecko.telemetry.stores.TelemetryPingStore;
@@ -80,16 +82,22 @@ public class TelemetryBackgroundReceiver
         LocalBroadcastManager.getInstance(context).registerReceiver(
                 this, new IntentFilter(ACTION_BACKGROUND_TELEMETRY));
     }
 
     @Override
     public void onReceive(final Context context, final Intent intent) {
         Log.i(LOG_TAG, "Handling background telemetry broadcast");
 
+        // This is our kill-switch for background telemetry (or a functionality throttle).
+        if (!SwitchBoard.isInExperiment(context, Experiments.ENABLE_PROCESSING_BACKGROUND_TELEMETRY)) {
+            Log.i(LOG_TAG, "Background telemetry processing disabled via switchboard.");
+            return;
+        }
+
         if (!intent.hasExtra(TelemetryContract.KEY_TELEMETRY)) {
             throw new IllegalStateException("Received a background telemetry broadcast without data.");
         }
 
         if (!intent.hasExtra(TelemetryContract.KEY_TYPE)) {
             throw new IllegalStateException("Received a background telemetry broadcast without type.");
         }