Backed out changeset ad857edac6a5 (bug 1498163) for failing devtools/client/performance/test/browser_perf-telemetry-04.js on a CLOSED TREE
authorAndreea Pavel <apavel@mozilla.com>
Tue, 27 Nov 2018 11:05:28 +0200
changeset 507422 f2ce8f83a2242f896a25043077539882993335ec
parent 507421 93fccab4f951f154e61e87081ceae912d16db025
child 507423 359e81b35cfb72928457964fcf1c826db1404818
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1498163
milestone65.0a1
backs outad857edac6a5944891e6ee1637f85f45c7f4f027
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
Backed out changeset ad857edac6a5 (bug 1498163) for failing devtools/client/performance/test/browser_perf-telemetry-04.js on a CLOSED TREE
browser/base/content/test/trackingUI/browser_trackingUI_telemetry.js
browser/modules/test/browser/browser_BrowserErrorReporter.js
browser/modules/test/browser/browser_BrowserErrorReporter_nightly.js
browser/modules/test/browser/browser_UsageTelemetry.js
browser/modules/test/browser/head.js
devtools/client/shared/test/telemetry-test-helpers.js
dom/base/test/browser_use_counters.js
dom/ipc/tests/browser_remote_navigation_delay_telemetry.js
dom/webauthn/tests/browser/browser_webauthn_telemetry.js
security/manager/ssl/tests/unit/test_pkcs11_module.js
services/sync/modules-testing/utils.js
toolkit/components/extensions/test/xpcshell/head_telemetry.js
toolkit/components/extensions/test/xpcshell/test_ext_telemetry.js
toolkit/components/osfile/tests/xpcshell/test_telemetry.js
toolkit/components/telemetry/tests/unit/test_TelemetryScalars.js
toolkit/components/terminator/tests/xpcshell/test_terminator_reload.js
--- a/browser/base/content/test/trackingUI/browser_trackingUI_telemetry.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_telemetry.js
@@ -31,17 +31,18 @@ add_task(async function setup() {
   let TrackingProtection = gBrowser.ownerGlobal.TrackingProtection;
   ok(TrackingProtection, "TP is attached to the browser window");
   ok(!TrackingProtection.enabled, "TP is not enabled");
 
   let enabledCounts =
     Services.telemetry.getHistogramById("TRACKING_PROTECTION_ENABLED").snapshot().values;
   is(enabledCounts[0], 1, "TP was not enabled on start up");
 
-  let scalars = Services.telemetry.getSnapshotForScalars("main", false).parent;
+  let scalars = Services.telemetry.snapshotScalars(
+    Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT, false).parent;
 
   is(scalars["contentblocking.exceptions"], 0, "no CB exceptions at startup");
 });
 
 
 add_task(async function testShieldHistogram() {
   Services.prefs.setBoolPref(PREF, true);
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
--- a/browser/modules/test/browser/browser_BrowserErrorReporter.js
+++ b/browser/modules/test/browser/browser_BrowserErrorReporter.js
@@ -108,29 +108,30 @@ add_task(async function testScalars() {
     createScriptError({message: "Whatever", stack: [frame()]}),
   ];
 
   // Use handleMessage to avoid errors from other code messing up our counts.
   for (const message of messages) {
     await reporter.handleMessage(message);
   }
 
-  const scalars = Services.telemetry.getSnapshotForScalars("main", false).parent;
+  const optin = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN;
+  const scalars = Services.telemetry.snapshotScalars(optin, false).parent;
   is(
     scalars[TELEMETRY_ERROR_COLLECTED],
     7,
     `${TELEMETRY_ERROR_COLLECTED} is incremented when an error is collected.`,
   );
   is(
     scalars[TELEMETRY_ERROR_COLLECTED_STACK],
     1,
     `${TELEMETRY_ERROR_REPORTED_FAIL} is incremented when an error with a stack trace is collected.`,
   );
 
-  const keyedScalars = Services.telemetry.getSnapshotForKeyedScalars("main", false).parent;
+  const keyedScalars = Services.telemetry.snapshotKeyedScalars(optin, false).parent;
   Assert.deepEqual(
     keyedScalars[TELEMETRY_ERROR_COLLECTED_FILENAME],
     {
       "FILTERED": 1,
       "MOZEXTENSION": 1,
       "resource://gre/modules/Foo.jsm": 1,
       "resource://gre/modules/Bar.jsm": 1,
       // Cut off at 70-character limit
@@ -175,17 +176,17 @@ add_task(async function testCollectedFil
 
     // Use handleMessage to avoid errors from other code messing up our counts.
     await reporter.handleMessage(createScriptError({
       message: "Fine",
       sourceName: filename,
     }));
 
     const keyedScalars = (
-      Services.telemetry.getSnapshotForKeyedScalars("main", false).parent
+      Services.telemetry.snapshotKeyedScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false).parent
     );
 
     let matched = null;
     if (shouldMatch) {
       matched = keyedScalars[TELEMETRY_ERROR_COLLECTED_FILENAME][filename] === 1;
     } else {
       matched = keyedScalars[TELEMETRY_ERROR_COLLECTED_FILENAME].FILTERED === 1;
     }
--- a/browser/modules/test/browser/browser_BrowserErrorReporter_nightly.js
+++ b/browser/modules/test/browser/browser_BrowserErrorReporter_nightly.js
@@ -443,17 +443,18 @@ add_task(async function testScalars() {
   await SpecialPowers.pushPrefEnv({set: [[PREF_SAMPLE_RATE, "0.0"]]});
   await reporter.handleMessage(createScriptError({message: "Additionally no name"}));
 
   // Failed fetches should be counted too
   await SpecialPowers.pushPrefEnv({set: [[PREF_SAMPLE_RATE, "1.0"]]});
   fetchStub.rejects(new Error("Could not report"));
   await reporter.handleMessage(createScriptError({message: "Maybe name?"}));
 
-  const scalars = Services.telemetry.getSnapshotForScalars("main", false).parent;
+  const optin = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN;
+  const scalars = Services.telemetry.snapshotScalars(optin, false).parent;
   is(
     scalars[TELEMETRY_ERROR_COLLECTED],
     3,
     `${TELEMETRY_ERROR_COLLECTED} is incremented when an error is collected.`,
   );
   is(
     scalars[TELEMETRY_ERROR_SAMPLE_RATE],
     "1.0",
--- a/browser/modules/test/browser/browser_UsageTelemetry.js
+++ b/browser/modules/test/browser/browser_UsageTelemetry.js
@@ -112,19 +112,20 @@ add_task(async function test_subsessionS
   // (about:mozilla and www.example.com, but no about:blank) and 1 URI totalURIs
   // (only www.example.com).
   checkScalars({maxTabs: 5, tabOpenCount: 4, maxWindows: 2, windowsOpenCount: 1,
                 totalURIs: 1, domainCount: 1, totalUnfilteredURIs: 2});
 
   // Remove a tab.
   BrowserTestUtils.removeTab(openedTabs.pop());
 
-  // Simulate a subsession split by clearing the scalars (via |getSnapshotForScalars|) and
+  // Simulate a subsession split by clearing the scalars (via |snapshotScalars|) and
   // notifying the subsession split topic.
-  Services.telemetry.getSnapshotForScalars("main", true /* clearScalars */);
+  Services.telemetry.snapshotScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                     true /* clearScalars */);
   Services.obs.notifyObservers(null, TELEMETRY_SUBSESSION_TOPIC);
 
   // After a subsession split, only the MAX_CONCURRENT_* scalars must be available
   // and have the correct value. No tabs, windows or URIs were opened so other scalars
   // must not be reported.
   checkScalars({maxTabs: 4, tabOpenCount: 0, maxWindows: 2, windowsOpenCount: 0,
                 totalURIs: 0, domainCount: 0, totalUnfilteredURIs: 0});
 
--- a/browser/modules/test/browser/head.js
+++ b/browser/modules/test/browser/head.js
@@ -134,23 +134,19 @@ function checkKeyedHistogram(h, key, exp
   Assert.ok(key in snapshot, `The histogram must contain ${key}.`);
   Assert.equal(snapshot[key].sum, expectedValue, `The key ${key} must contain ${expectedValue}.`);
 }
 
 /**
  * Return the scalars from the parent-process.
  */
 function getParentProcessScalars(aChannel, aKeyed = false, aClear = false) {
-  const extended = aChannel == Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN;
-  const currentExtended = Services.telemetry.canRecordExtended;
-  Services.telemetry.canRecordExtended = extended;
   const scalars = aKeyed ?
-    Services.telemetry.getSnapshotForKeyedScalars("main", aClear).parent :
-    Services.telemetry.getSnapshotForScalars("main", aClear).parent;
-  Services.telemetry.canRecordExtended = currentExtended;
+    Services.telemetry.snapshotKeyedScalars(aChannel, aClear).parent :
+    Services.telemetry.snapshotScalars(aChannel, aClear).parent;
   return scalars || {};
 }
 
 function checkEvents(events, expectedEvents) {
   if (!Services.telemetry.canRecordExtended) {
     // Currently we only collect the tested events when extended Telemetry is enabled.
     return;
   }
--- a/devtools/client/shared/test/telemetry-test-helpers.js
+++ b/devtools/client/shared/test/telemetry-test-helpers.js
@@ -25,45 +25,53 @@ class TelemetryHelpers {
 
   /**
    * Clear all telemetry types.
    */
   stopTelemetry() {
     Services.telemetry.canRecordExtended = this.oldCanRecord;
 
     // Clear histograms, scalars and Telemetry Events.
-    this.clearHistograms(Services.telemetry.getSnapshotForHistograms);
-    this.clearHistograms(Services.telemetry.getSnapshotForKeyedHistograms);
+    this.clearHistograms(Services.telemetry.snapshotHistograms);
+    this.clearHistograms(Services.telemetry.snapshotKeyedHistograms);
     Services.telemetry.clearScalars();
     Services.telemetry.clearEvents();
   }
 
   /**
+   * Clears both OPTIN and OPTOUT versions of Telemetry Histograms.
+   *
    * @param {Function} snapshotFunc
    *        The function used to take the snapshot. This can be one of the
    *        following:
-   *          - Services.telemetry.getSnapshotForHistograms
-   *          - Services.telemetry.getSnapshotForKeyedHistograms
+   *          - Services.telemetry.snapshotHistograms
+   *          - Services.telemetry.snapshotKeyedHistograms
    *
-   *        `snapshotFunc("main", true)` should clear the histograms but this
+   *        `snapshotFunc(OPTIN, true, true)` should clear the histograms but this
    *        only deletes seemingly random histograms, hence this method.
    */
   clearHistograms(snapshotFunc) {
+    // Although most of our Telemetry probes are OPTOUT, OPTIN includes all OPTIN
+    // *and* OPTOUT data.
+    const OPTIN = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN;
+    const OPTOUT = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT;
     const tel = Services.telemetry;
 
-    const snapshot = snapshotFunc("main", true).parent;
-    const histKeys = Object.keys(snapshot);
+    for (const optInOut of [OPTIN, OPTOUT]) {
+      const snapshot = snapshotFunc(optInOut, true, false).parent;
+      const histKeys = Object.keys(snapshot);
 
-    for (const getHistogram of [tel.getHistogramById, tel.getKeyedHistogramById]) {
-      for (const key of histKeys) {
-        try {
-          getHistogram(key).clear();
-        } catch (e) {
-          // Some histograms may have already been cleaned up by the system so we
-          // swallow the "histogram does not exist" error silently here.
+      for (const getHistogram of [tel.getHistogramById, tel.getKeyedHistogramById]) {
+        for (const key of histKeys) {
+          try {
+            getHistogram(key).clear();
+          } catch (e) {
+            // Some histograms may have already been cleaned up by the system so we
+            // swallow the "histogram does not exist" error silently here.
+          }
         }
       }
     }
   }
 
   /**
    * Check the value of a given telemetry histogram.
    *
@@ -76,16 +84,20 @@ class TelemetryHelpers {
    * @param  {String} checkType
    *         "array" (default) - Check that an array matches the histogram data.
    *         "hasentries"  - For non-enumerated linear and exponential
    *                             histograms. This checks for at least one entry.
    *         "scalar" - Telemetry type is a scalar.
    *         "keyedscalar" - Telemetry type is a keyed scalar.
    */
   checkTelemetry(histId, key, expected, checkType) {
+    // Although most of our Telemetry probes are OPTOUT, OPTIN includes all OPTIN
+    // *and* OPTOUT data.
+    const OPTIN = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN;
+
     let actual;
     let msg;
 
     if (checkType === "array" || checkType === "hasentries") {
       if (key) {
         const keyedHistogram =
           Services.telemetry.getKeyedHistogramById(histId).snapshot();
         const result = keyedHistogram[key];
@@ -111,23 +123,23 @@ class TelemetryHelpers {
         if (key) {
           ok(hasEntry, `${histId}["${key}"] has at least one entry.`);
         } else {
           ok(hasEntry, `${histId} has at least one entry.`);
         }
         break;
       case "scalar":
         const scalars =
-          Services.telemetry.getSnapshotForScalars("main", false).parent;
+          Services.telemetry.snapshotScalars(OPTIN, false).parent;
 
         is(scalars[histId], expected, `${histId} correct`);
         break;
       case "keyedscalar":
         const keyedScalars =
-          Services.telemetry.getSnapshotForKeyedScalars("main", false).parent;
+          Services.telemetry.snapshotKeyedScalars(OPTIN, false).parent;
         const value = keyedScalars[histId][key];
 
         msg = key ? `${histId}["${key}"] correct.` : `${histId} correct.`;
         is(value, expected, msg);
         break;
     }
   }
 
@@ -135,25 +147,29 @@ class TelemetryHelpers {
    * Generate telemetry tests. You should call generateTelemetryTests("DEVTOOLS_")
    * from your result checking code in telemetry tests. It logs checkTelemetry
    * calls for all changed telemetry values.
    *
    * @param  {String} prefix
    *         Optionally limits results to histogram ids starting with prefix.
    */
   generateTelemetryTests(prefix = "") {
+    // Although most of our Telemetry probes are OPTOUT, OPTIN includes all OPTIN
+    // *and* OPTOUT data.
+    const OPTIN = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN;
+
     // Get all histograms and scalars
     const histograms =
-      Services.telemetry.getSnapshotForHistograms("main", true).parent;
+      Services.telemetry.snapshotHistograms(OPTIN, true, false).parent;
     const keyedHistograms =
-      Services.telemetry.getSnapshotForKeyedHistograms("main", true).parent;
+      Services.telemetry.snapshotKeyedHistograms(OPTIN, true, false).parent;
     const scalars =
-      Services.telemetry.getSnapshotForScalars("main", false).parent;
+      Services.telemetry.snapshotScalars(OPTIN, false).parent;
     const keyedScalars =
-      Services.telemetry.getSnapshotForKeyedScalars("main", false).parent;
+      Services.telemetry.snapshotKeyedScalars(OPTIN, false).parent;
     const allHistograms = Object.assign({},
                                         histograms,
                                         keyedHistograms,
                                         scalars,
                                         keyedScalars);
     // Get all keys
     const histIds = Object.keys(allHistograms)
                           .filter(histId => histId.startsWith(prefix));
@@ -196,17 +212,17 @@ class TelemetryHelpers {
     }
     dump("=".repeat(80) + "\n");
   }
 
   /**
    * Generates the inner contents of a test's checkTelemetry() method.
    *
    * @param {HistogramSnapshot} snapshot
-   *        A snapshot of a telemetry chart obtained via getSnapshotForHistograms or
+   *        A snapshot of a telemetry chart obtained via snapshotHistograms or
    *        similar.
    * @param {String} key
    *        Only used for keyed histograms. This is the key we are interested in
    *        checking.
    * @param {String} histId
    *        The histogram ID.
    * @param {Array|String|Boolean} actual
    *        The value of the histogram data.
--- a/dom/base/test/browser_use_counters.js
+++ b/dom/base/test/browser_use_counters.js
@@ -106,19 +106,19 @@ function waitForPageLoad(browser) {
   });
 }
 
 function grabHistogramsFromContent(use_counter_middlefix, page_before = null) {
   let telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
   let gather = () => {
     let snapshots;
     if (Services.appinfo.browserTabsRemoteAutostart) {
-      snapshots = telemetry.getSnapshotForHistograms("main", false).content;
+      snapshots = telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false).content;
     } else {
-      snapshots = telemetry.getSnapshotForHistograms("main", false).parent;
+      snapshots = telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false).parent;
     }
     let checkGet = (probe) => {
       return snapshots[probe] ? snapshots[probe].sum : 0;
     };
     return [
       checkGet("USE_COUNTER2_" + use_counter_middlefix + "_PAGE"),
       checkGet("USE_COUNTER2_" + use_counter_middlefix + "_DOCUMENT"),
       checkGet("CONTENT_DOCUMENTS_DESTROYED"),
@@ -165,17 +165,17 @@ var check_use_counter_iframe = async fun
       wu.forceUseCounterFlush(iframe.contentDocument);
 
       deferred.resolve();
     };
     iframe.addEventListener("load", listener, true);
 
     return deferred.promise;
   });
-
+  
   // Tear down the page.
   gBrowser.removeTab(newTab);
 
   // The histograms only get recorded when the document actually gets
   // destroyed, which might not have happened yet due to GC/CC effects, etc.
   // Try to force document destruction.
   await waitForDestroyedDocuments();
 
@@ -230,17 +230,17 @@ var check_use_counter_img = async functi
       wu.forceUseCounterFlush(content.document);
 
       deferred.resolve();
     };
     img.addEventListener("load", listener, true);
 
     return deferred.promise;
   });
-
+  
   // Tear down the page.
   gBrowser.removeTab(newTab);
 
   // The histograms only get recorded when the document actually gets
   // destroyed, which might not have happened yet due to GC/CC effects, etc.
   // Try to force document destruction.
   await waitForDestroyedDocuments();
 
@@ -283,17 +283,17 @@ var check_use_counter_direct = async fun
         let wu = content.window.windowUtils;
         wu.forceUseCounterFlush(content.document);
 
         setTimeout(resolve, 0);
       }
       addEventListener("load", listener, true);
     });
   });
-
+  
   // Tear down the page.
   gBrowser.removeTab(newTab);
 
   // The histograms only get recorded when the document actually gets
   // destroyed, which might not have happened yet due to GC/CC effects, etc.
   // Try to force document destruction.
   await waitForDestroyedDocuments();
 
--- a/dom/ipc/tests/browser_remote_navigation_delay_telemetry.js
+++ b/dom/ipc/tests/browser_remote_navigation_delay_telemetry.js
@@ -7,42 +7,45 @@ add_task(async function test_memory_dist
     ok(true, "Skip this test if e10s-multi is disabled.");
     return;
   }
 
   let canRecordExtended = Services.telemetry.canRecordExtended;
   Services.telemetry.canRecordExtended = true;
   registerCleanupFunction(() => Services.telemetry.canRecordExtended = canRecordExtended);
 
-  Services.telemetry.getSnapshotForKeyedHistograms("main", true /* clear */);
+  Services.telemetry.snapshotKeyedHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                             true /* clear */);
 
   // Open a remote page in a new tab to trigger the WebNavigation:LoadURI.
   let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com");
   ok(tab1.linkedBrowser.isRemoteBrowser, "|tab1| should have a remote browser.");
 
   // Open a new tab with about:robots, so it ends up in the parent process with a non-remote browser.
   let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:robots");
   ok(!tab2.linkedBrowser.isRemoteBrowser, "|tab2| should have a non-remote browser.");
   // Navigate the tab, so it will change remotness and it triggers the SessionStore:restoreTabContent case.
   await BrowserTestUtils.loadURI(tab2.linkedBrowser, "http://example.com");
   ok(tab2.linkedBrowser.isRemoteBrowser, "|tab2| should have a remote browser by now.");
 
   // There is no good way to make sure that the parent received the histogram entries from the child processes.
   // Let's stick to the ugly, spinning the event loop until we have a good approach (Bug 1357509).
   await BrowserTestUtils.waitForCondition(() => {
-    let s = Services.telemetry.getSnapshotForKeyedHistograms("main", false).content["FX_TAB_REMOTE_NAVIGATION_DELAY_MS"];
+    let s = Services.telemetry.snapshotKeyedHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                                       false).content["FX_TAB_REMOTE_NAVIGATION_DELAY_MS"];
     return s && "WebNavigation:LoadURI" in s && "SessionStore:restoreTabContent" in s;
   });
 
-  let s = Services.telemetry.getSnapshotForKeyedHistograms("main", false).content["FX_TAB_REMOTE_NAVIGATION_DELAY_MS"];
+  let s = Services.telemetry.snapshotKeyedHistograms(1, false).content["FX_TAB_REMOTE_NAVIGATION_DELAY_MS"];
   let restoreTabSnapshot = s["SessionStore:restoreTabContent"];
   ok(restoreTabSnapshot.sum > 0, "Zero delay for the restoreTabContent case is unlikely.");
   ok(restoreTabSnapshot.sum < 10000, "More than 10 seconds delay for the restoreTabContent case is unlikely.");
 
   let loadURISnapshot = s["WebNavigation:LoadURI"];
   ok(loadURISnapshot.sum > 0, "Zero delay for the LoadURI case is unlikely.");
   ok(loadURISnapshot.sum < 10000, "More than 10 seconds delay for the LoadURI case is unlikely.");
 
-  Services.telemetry.getSnapshotForKeyedHistograms("main", true /* clear */);
+  Services.telemetry.snapshotKeyedHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                             true /* clear */);
 
   BrowserTestUtils.removeTab(tab2);
   BrowserTestUtils.removeTab(tab1);
 });
--- a/dom/webauthn/tests/browser/browser_webauthn_telemetry.js
+++ b/dom/webauthn/tests/browser/browser_webauthn_telemetry.js
@@ -2,25 +2,25 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const TEST_URL = "https://example.com/";
 
 // Return the scalars from the parent-process.
-function getParentProcessScalars(aKeyed = false, aClear = false) {
+function getParentProcessScalars(aChannel, aKeyed = false, aClear = false) {
   const scalars = aKeyed ?
-    Services.telemetry.getSnapshotForKeyedScalars("main", aClear)["parent"] :
-    Services.telemetry.getSnapshotForScalars("main", aClear)["parent"];
+    Services.telemetry.snapshotKeyedScalars(aChannel, aClear)["parent"] :
+    Services.telemetry.snapshotScalars(aChannel, aClear)["parent"];
   return scalars || {};
 }
 
 function getTelemetryForScalar(aName) {
-  let scalars = getParentProcessScalars(true);
+  let scalars = getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT, true);
   return scalars[aName] || 0;
 }
 
 function cleanupTelemetry() {
   Services.telemetry.clearScalars();
   Services.telemetry.clearEvents();
   Services.telemetry.getHistogramById("WEBAUTHN_CREATE_CREDENTIAL_MS").clear();
   Services.telemetry.getHistogramById("WEBAUTHN_GET_ASSERTION_MS").clear();
--- a/security/manager/ssl/tests/unit/test_pkcs11_module.js
+++ b/security/manager/ssl/tests/unit/test_pkcs11_module.js
@@ -53,17 +53,18 @@ function checkTestModuleExists() {
 function checkModuleTelemetry(additionalExpectedModule = undefined) {
   let expectedModules = [
     "NSS Internal PKCS #11 Module",
   ];
   if (additionalExpectedModule) {
     expectedModules.push(additionalExpectedModule);
   }
   expectedModules.sort();
-  let telemetry = Services.telemetry.getSnapshotForKeyedScalars("main", false).parent;
+  let telemetry = Services.telemetry.snapshotKeyedScalars(
+    Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT).parent;
   let moduleTelemetry = telemetry["security.pkcs11_modules_loaded"];
   let actualModules = [];
   Object.keys(moduleTelemetry).forEach((key) => {
     ok(moduleTelemetry[key], "each keyed scalar should be true");
     actualModules.push(key);
   });
   actualModules.sort();
   equal(actualModules.length, expectedModules.length,
--- a/services/sync/modules-testing/utils.js
+++ b/services/sync/modules-testing/utils.js
@@ -284,11 +284,12 @@ var sumHistogram = function(name, option
       sum = snapshot.sum;
     }
   }
   histogram.clear();
   return sum;
 };
 
 var getLoginTelemetryScalar = function() {
-  let snapshot = Services.telemetry.getSnapshotForKeyedScalars("main", true);
+  let dataset = Services.telemetry.DATASET_RELEASE_CHANNEL_OPTOUT;
+  let snapshot = Services.telemetry.snapshotKeyedScalars(dataset, true);
   return snapshot.parent ? snapshot.parent["services.sync.sync_login_state_transitions"] : {};
 };
--- a/toolkit/components/extensions/test/xpcshell/head_telemetry.js
+++ b/toolkit/components/extensions/test/xpcshell/head_telemetry.js
@@ -9,44 +9,48 @@ ChromeUtils.defineModuleGetter(this, "Co
 
 const IS_OOP = Services.prefs.getBoolPref("extensions.webextensions.remote");
 
 function valueSum(arr) {
   return Object.values(arr).reduce((a, b) => a + b, 0);
 }
 
 function clearHistograms() {
-  Services.telemetry.getSnapshotForHistograms("main", true /* clear */);
-  Services.telemetry.getSnapshotForKeyedHistograms("main", true /* clear */);
+  Services.telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                        true /* clear */);
+  Services.telemetry.snapshotKeyedHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                             true /* clear */);
 }
 
 function getSnapshots(process) {
-  return Services.telemetry.getSnapshotForHistograms("main", false /* clear */)[process];
+  return Services.telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                               false /* clear */)[process];
 }
 
 function getKeyedSnapshots(process) {
-  return Services.telemetry.getSnapshotForKeyedHistograms("main", false /* clear */)[process];
+  return Services.telemetry.snapshotKeyedHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                                    false /* clear */)[process];
 }
 
 // TODO Bug 1357509: There is no good way to make sure that the parent received
 // the histogram entries from the extension and content processes.  Let's stick
 // to the ugly, spinning the event loop until we have a good approach.
 function promiseTelemetryRecorded(id, process, expectedCount) {
   let condition = () => {
-    let snapshot = Services.telemetry.getSnapshotForHistograms("main",
-                                                               false /* clear */)[process][id];
+    let snapshot = Services.telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                                         false /* clear */)[process][id];
     return snapshot && valueSum(snapshot.values) >= expectedCount;
   };
   return ContentTaskUtils.waitForCondition(condition);
 }
 
 function promiseKeyedTelemetryRecorded(id, process, expectedKey, expectedCount) {
   let condition = () => {
-    let snapshot = Services.telemetry.getSnapshotForKeyedHistograms("main",
-                                                                    false /* clear */)[process][id];
+    let snapshot = Services.telemetry.snapshotKeyedHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                                              false /* clear */)[process][id];
     return snapshot && snapshot[expectedKey] && valueSum(snapshot[expectedKey].values) >= expectedCount;
   };
   return ContentTaskUtils.waitForCondition(condition);
 }
 
 function assertHistogramSnapshot(histogramId, {keyed, processSnapshot, expectedValue}, msg) {
   let histogram;
 
--- a/toolkit/components/extensions/test/xpcshell/test_ext_telemetry.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_telemetry.js
@@ -38,17 +38,17 @@ if (AppConstants.MOZ_BUILD_APP === "brow
     await run({
       backgroundScript: async () => {
         await browser.telemetry.scalarAdd("telemetry.test.unsigned_int_kind", 1);
         browser.test.notifyPass("scalar_add");
       },
       doneSignal: "scalar_add",
     });
 
-    const scalars = Services.telemetry.getSnapshotForScalars("main", false);
+    const scalars = Services.telemetry.snapshotScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
     equal(scalars.parent["telemetry.test.unsigned_int_kind"], 1);
 
     Services.telemetry.clearScalars();
   });
 
   add_task(async function test_telemetry_scalar_add_unknown_name() {
     let {messages} = await promiseConsoleOutput(async () => {
       await run({
@@ -99,17 +99,17 @@ if (AppConstants.MOZ_BUILD_APP === "brow
     await run({
       backgroundScript: async () => {
         await browser.telemetry.scalarSet("telemetry.test.boolean_kind", true);
         browser.test.notifyPass("scalar_set");
       },
       doneSignal: "scalar_set",
     });
 
-    const scalars = Services.telemetry.getSnapshotForScalars("main", false);
+    const scalars = Services.telemetry.snapshotScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
     equal(scalars.parent["telemetry.test.boolean_kind"], true);
 
     Services.telemetry.clearScalars();
   });
 
   add_task(async function test_telemetry_scalar_set_unknown_name() {
     let {messages} = await promiseConsoleOutput(async function() {
       await run({
@@ -131,17 +131,17 @@ if (AppConstants.MOZ_BUILD_APP === "brow
     await run({
       backgroundScript: async () => {
         await browser.telemetry.scalarSetMaximum("telemetry.test.unsigned_int_kind", 123);
         browser.test.notifyPass("scalar_set_maximum");
       },
       doneSignal: "scalar_set_maximum",
     });
 
-    const scalars = Services.telemetry.getSnapshotForScalars("main", false);
+    const scalars = Services.telemetry.snapshotScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
     equal(scalars.parent["telemetry.test.unsigned_int_kind"], 123);
 
     Services.telemetry.clearScalars();
   });
 
   add_task(async function test_telemetry_scalar_set_maximum_unknown_name() {
     let {messages} = await promiseConsoleOutput(async function() {
       await run({
@@ -203,17 +203,17 @@ if (AppConstants.MOZ_BUILD_APP === "brow
           },
         });
         await browser.telemetry.scalarSet("telemetry.test.dynamic.webext_string", "hello");
         browser.test.notifyPass("register_scalars_string");
       },
       doneSignal: "register_scalars_string",
     });
 
-    const scalars = Services.telemetry.getSnapshotForScalars("main", false);
+    const scalars = Services.telemetry.snapshotScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
     equal(scalars.dynamic["telemetry.test.dynamic.webext_string"], "hello");
 
     Services.telemetry.clearScalars();
   });
 
   add_task(async function test_telemetry_register_scalars_multiple() {
     Services.telemetry.clearScalars();
 
@@ -233,17 +233,17 @@ if (AppConstants.MOZ_BUILD_APP === "brow
         });
         await browser.telemetry.scalarSet("telemetry.test.dynamic.webext_string", "hello");
         await browser.telemetry.scalarSet("telemetry.test.dynamic.webext_string_too", "world");
         browser.test.notifyPass("register_scalars_multiple");
       },
       doneSignal: "register_scalars_multiple",
     });
 
-    const scalars = Services.telemetry.getSnapshotForScalars("main", false);
+    const scalars = Services.telemetry.snapshotScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
     equal(scalars.dynamic["telemetry.test.dynamic.webext_string"], "hello");
     equal(scalars.dynamic["telemetry.test.dynamic.webext_string_too"], "world");
 
     Services.telemetry.clearScalars();
   });
 
   add_task(async function test_telemetry_register_scalars_boolean() {
     Services.telemetry.clearScalars();
@@ -258,17 +258,17 @@ if (AppConstants.MOZ_BUILD_APP === "brow
           },
         });
         await browser.telemetry.scalarSet("telemetry.test.dynamic.webext_boolean", true);
         browser.test.notifyPass("register_scalars_boolean");
       },
       doneSignal: "register_scalars_boolean",
     });
 
-    const scalars = Services.telemetry.getSnapshotForScalars("main", false);
+    const scalars = Services.telemetry.snapshotScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
     equal(scalars.dynamic["telemetry.test.dynamic.webext_boolean"], true);
 
     Services.telemetry.clearScalars();
   });
 
   add_task(async function test_telemetry_register_scalars_count() {
     Services.telemetry.clearScalars();
 
@@ -282,17 +282,17 @@ if (AppConstants.MOZ_BUILD_APP === "brow
           },
         });
         await browser.telemetry.scalarSet("telemetry.test.dynamic.webext_count", 123);
         browser.test.notifyPass("register_scalars_count");
       },
       doneSignal: "register_scalars_count",
     });
 
-    const scalars = Services.telemetry.getSnapshotForScalars("main", false);
+    const scalars = Services.telemetry.snapshotScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN);
     equal(scalars.dynamic["telemetry.test.dynamic.webext_count"], 123);
 
     Services.telemetry.clearScalars();
   });
 
   add_task(async function test_telemetry_register_events() {
     Services.telemetry.clearEvents();
 
--- a/toolkit/components/osfile/tests/xpcshell/test_telemetry.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_telemetry.js
@@ -22,38 +22,42 @@ function getCount(histogram) {
 }
 
 // Ensure that launching the OS.File worker adds data to the relevant
 // histograms
 add_task(async function test_startup() {
   let LAUNCH = "OSFILE_WORKER_LAUNCH_MS";
   let READY = "OSFILE_WORKER_READY_MS";
 
-  let before = Services.telemetry.getSnapshotForHistograms("main", false).parent;
+  let before = Services.telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                                     false).parent;
 
   // Launch the OS.File worker
   await File.getCurrentDirectory();
 
-  let after = Services.telemetry.getSnapshotForHistograms("main", false).parent;
+  let after = Services.telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                                    false).parent;
 
 
   info("Ensuring that we have recorded measures for histograms");
   Assert.equal(getCount(after[LAUNCH]), getCount(before[LAUNCH]) + 1);
   Assert.equal(getCount(after[READY]), getCount(before[READY]) + 1);
 
   info("Ensuring that launh <= ready");
   Assert.ok(after[LAUNCH].sum <= after[READY].sum);
 });
 
 // Ensure that calling writeAtomic adds data to the relevant histograms
 add_task(async function test_writeAtomic() {
   let LABEL = "OSFILE_WRITEATOMIC_JANK_MS";
 
-  let before = Services.telemetry.getSnapshotForHistograms("main", false).parent;
+  let before = Services.telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                                     false).parent;
 
   // Perform a write.
   let path = Path.join(Constants.Path.profileDir, "test_osfile_telemetry.tmp");
   await File.writeAtomic(path, LABEL, { tmpPath: path + ".tmp" } );
 
-  let after = Services.telemetry.getSnapshotForHistograms("main", false).parent;
+  let after = Services.telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                                    false).parent;
 
   Assert.equal(getCount(after[LABEL]), getCount(before[LABEL]) + 1);
 });
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryScalars.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryScalars.js
@@ -527,17 +527,17 @@ add_task(async function test_keyed_max_k
 
   // Add 100 keys to the keyed exceed scalar and set their initial value.
   valueToSet = 0;
   keyNamesSet2.forEach(keyName2 => {
     Telemetry.keyedScalarSet(KEYED_EXCEED_SCALAR, keyName2, valueToSet++);
   });
 
   // Check that there are exactly 100 keys in KEYED_EXCEED_SCALAR
-  let snapshot = Telemetry.getSnapshotForKeyedScalars("main", false);
+  let snapshot = Telemetry.snapshotKeyedScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
   Assert.equal(100, Object.keys(snapshot.parent[KEYED_UINT_SCALAR]).length,
              "The keyed scalar must contain all the 100 keys.");
 
   // Check that KEYED_UINT_SCALAR is in keyedScalars and its value equals 3
   Assert.ok((KEYED_UINT_SCALAR in keyedScalars[KEYED_EXCEED_SCALAR]), "The keyed Scalar is in the keyed exceeded scalar");
   Assert.equal(keyedScalars[KEYED_EXCEED_SCALAR][KEYED_UINT_SCALAR], 3, "We have exactly 3 keys over the limit");
 });
 
--- a/toolkit/components/terminator/tests/xpcshell/test_terminator_reload.js
+++ b/toolkit/components/terminator/tests/xpcshell/test_terminator_reload.js
@@ -24,18 +24,18 @@ var HISTOGRAMS = {
 add_task(async function init() {
   do_get_profile();
   PATH = Path.join(Constants.Path.localProfileDir, "ShutdownDuration.json");
 });
 
 add_task(async function test_reload() {
   info("Forging data");
   let data = {};
-  let telemetrySnapshots = Services.telemetry.getSnapshotForHistograms("main",
-                                                                       false /* clear */).parent;
+  let telemetrySnapshots = Services.telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                                                 false /* clear */).parent;
   let i = 0;
   for (let k of Object.keys(HISTOGRAMS)) {
     let id = HISTOGRAMS[k];
     data[k] = i++;
     Assert.equal(telemetrySnapshots[id] || undefined, undefined, "Histogram " + id + " is empty");
   }
 
 
@@ -56,18 +56,18 @@ add_task(async function test_reload() {
   let tt = Cc["@mozilla.org/toolkit/shutdown-terminator-telemetry;1"].
     createInstance(Ci.nsIObserver);
   tt.observe(null, "profile-after-change", "");
 
   info("Waiting until telemetry is updated");
   // Now wait until Telemetry is updated
   await wait;
 
-  telemetrySnapshots = Services.telemetry.getSnapshotForHistograms("main",
-                                                                   false /* clear */).parent;
+  telemetrySnapshots = Services.telemetry.snapshotHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN,
+                                                             false /* clear */).parent;
   for (let k of Object.keys(HISTOGRAMS)) {
     let id = HISTOGRAMS[k];
     info("Testing histogram " + id);
     let snapshot = telemetrySnapshots[id];
     let count = 0;
     for (let x of Object.values(snapshot.values)) {
       count += x;
     }