Backed out changeset 2ceb8a5a3e40 (bug 1318297) for xpcshell failures in test_TelemetryHealthPing.js
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Mon, 24 Jul 2017 16:16:40 +0200
changeset 370609 a035857a0533e01d312cf03cbc441a4a9a98e76e
parent 370608 3538dbc8dbfed1ca5153304f21f6c899e353750d
child 370610 601d05280d9e429aa419741382682a0b28b2d317
push id32228
push userkwierso@gmail.com
push dateTue, 25 Jul 2017 01:06:49 +0000
treeherdermozilla-central@dcfb58fcb6dd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1318297
milestone56.0a1
backs out2ceb8a5a3e409b0daf26fc0715b57976f0bf7d6b
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 2ceb8a5a3e40 (bug 1318297) for xpcshell failures in test_TelemetryHealthPing.js
toolkit/components/telemetry/TelemetryController.jsm
toolkit/components/telemetry/TelemetryHealthPing.jsm
toolkit/components/telemetry/TelemetrySend.jsm
toolkit/components/telemetry/TelemetryUtils.jsm
toolkit/components/telemetry/docs/internals/preferences.rst
toolkit/components/telemetry/moz.build
toolkit/components/telemetry/tests/unit/head.js
toolkit/components/telemetry/tests/unit/test_PingAPI.js
toolkit/components/telemetry/tests/unit/test_TelemetryController_idle.js
toolkit/components/telemetry/tests/unit/test_TelemetryHealthPing.js
toolkit/components/telemetry/tests/unit/test_TelemetrySend.js
toolkit/components/telemetry/tests/unit/xpcshell.ini
--- a/toolkit/components/telemetry/TelemetryController.jsm
+++ b/toolkit/components/telemetry/TelemetryController.jsm
@@ -71,18 +71,16 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetrySession",
                                   "resource://gre/modules/TelemetrySession.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetrySend",
                                   "resource://gre/modules/TelemetrySend.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetryReportingPolicy",
                                   "resource://gre/modules/TelemetryReportingPolicy.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetryModules",
                                   "resource://gre/modules/TelemetryModules.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "TelemetryHealthPing",
-                                  "resource://gre/modules/TelemetryHealthPing.jsm");
 
 /**
  * Setup Telemetry logging. This function also gets called when loggin related
  * preferences change.
  */
 var gLogger = null;
 var gLogAppenderDump = null;
 function configureLogging() {
@@ -785,19 +783,16 @@ var Impl = {
 
       // Stop the datachoices infobar display.
       TelemetryReportingPolicy.shutdown();
       TelemetryEnvironment.shutdown();
 
       // Stop any ping sending.
       await TelemetrySend.shutdown();
 
-      // Send latest data.
-      await TelemetryHealthPing.shutdown();
-
       await TelemetrySession.shutdown();
 
       // First wait for clients processing shutdown.
       await this._shutdownBarrier.wait();
 
       // ... and wait for any outstanding async ping activity.
       await this._connectionsBarrier.wait();
 
deleted file mode 100644
--- a/toolkit/components/telemetry/TelemetryHealthPing.jsm
+++ /dev/null
@@ -1,248 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-/*
- * This module collects data on send failures and other critical issues with Telemetry submissions.
- */
-
-"use strict";
-
-this.EXPORTED_SYMBOLS = [
-  "TelemetryHealthPing",
-];
-
-const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
-
-XPCOMUtils.defineLazyModuleGetter(this, "TelemetryController", "resource://gre/modules/TelemetryController.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "setTimeout", "resource://gre/modules/Timer.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "clearTimeout", "resource://gre/modules/Timer.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "TelemetryUtils", "resource://gre/modules/TelemetryUtils.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "TelemetrySend", "resource://gre/modules/TelemetrySend.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "Log", "resource://gre/modules/Log.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "Preferences", "resource://gre/modules/Preferences.jsm");
-
-const Utils = TelemetryUtils;
-
-const MS_IN_A_MINUTE = 60 * 1000;
-const IS_HEALTH_PING_ENABLED = Preferences.get("toolkit.telemetry.healthping.enabled", true);
-
-// Send health ping every hour
-const SEND_TICK_DELAY = 60 * MS_IN_A_MINUTE;
-
-// Send top 10 discarded pings only to minimize health ping size
-const MAX_SEND_DISCARDED_PINGS = 10;
-
-const LOGGER_NAME = "Toolkit.Telemetry";
-const LOGGER_PREFIX = "TelemetryHealthPing::";
-
-var Policy = {
-  setSchedulerTickTimeout: (callback, delayMs) => setTimeout(callback, delayMs),
-  clearSchedulerTickTimeout: (id) => clearTimeout(id)
-};
-
-this.TelemetryHealthPing = {
-  Reason: Object.freeze({
-    IMMEDIATE: "immediate", // Ping was sent immediately after recording with no delay.
-    DELAYED: "delayed",     // Recorded data was sent after a delay.
-    SHUT_DOWN: "shutdown",  // Recorded data was sent on shutdown.
-  }),
-
-  FailureType: Object.freeze({
-    DISCARDED_FOR_SIZE: "pingDiscardedForSize",
-    SEND_FAILURE: "sendFailure",
-  }),
-
-  OsInfo: Object.freeze({
-    "name": Services.appinfo.OS,
-    "version": Services.sysinfo.get("kernel_version") || Services.sysinfo.get("version")
-  }),
-
-  HEALTH_PING_TYPE: "health",
-
-  _logger: null,
-
-  // The health ping is sent every every SEND_TICK_DELAY.
-  // Initialize this so that first failures are sent immediately.
-  _lastSendTime: -SEND_TICK_DELAY,
-
-  /**
-   * This stores reported send failures with the following structure:
-   * {
-   *  type1: {
-   *    subtype1: value,
-   *    ...
-   *    subtypeN: value
-   *  },
-   *  ...
-   * }
-   */
-  _failures: {},
-  _timeoutId: null,
-
-  /**
-   * Record a failure to send a ping out.
-   * @param {String} failureType The type of failure (e.g. "timeout", ...).
-   * @returns {Promise} Test-only, resolved when the ping is stored or sent.
-   */
-  recordSendFailure(failureType) {
-    return this._addToFailure(this.FailureType.SEND_FAILURE, failureType);
-  },
-
-  /**
-   * Record that a ping was discarded and its type.
-   * @param {String} pingType The type of discarded ping (e.g. "main", ...).
-   * @returns {Promise} Test-only, resolved when the ping is stored or sent.
-   */
-  recordDiscardedPing(pingType) {
-    return this._addToFailure(this.FailureType.DISCARDED_FOR_SIZE, pingType);
-  },
-
-  /**
-   * Assemble payload.
-   * @param {String} reason A string indicating the triggering reason (e.g. "immediate", "delayed", "shutdown").
-   * @returns {Object} The assembled payload.
-   */
-  _assemblePayload(reason) {
-    this._log.trace("_assemblePayload()");
-    let payload = {
-      os: this.OsInfo,
-      reason
-    };
-
-    for (let key of Object.keys(this._failures)) {
-      if (key === this.FailureType.DISCARDED_FOR_SIZE) {
-        payload[key] = this._getTopDiscardFailures(this._failures[key]);
-      } else {
-        payload[key] = this._failures[key];
-      }
-    }
-
-    return payload;
-  },
-
-  /**
-   * Sort input dictionary descending by value.
-   * @param {Object} failures A dictionary of failures subtype and count.
-   * @returns {Object} Sorted failures by value.
-   */
-  _getTopDiscardFailures(failures) {
-    this._log.trace("_getTopDiscardFailures()");
-    let sortedItems = Object.entries(failures).sort((first, second) => {
-      return second[1] - first[1];
-    });
-
-    let result = {};
-    sortedItems.slice(0, MAX_SEND_DISCARDED_PINGS).forEach(([key, value]) => {
-      result[key] = value;
-    });
-
-    return result;
-  },
-
-  /**
-   * Assemble the failure information and submit it.
-   * @param {String} reason A string indicating the triggering reason (e.g. "immediate", "delayed", "shutdown").
-   * @returns {Promise} Test-only promise that resolves when the ping was stored or sent (if any).
-   */
-  _submitPing(reason) {
-    if (!IS_HEALTH_PING_ENABLED || !this._hasDataToSend()) {
-      return Promise.resolve();
-    }
-
-    this._log.trace("_submitPing(" + reason + ")");
-    let payload = this._assemblePayload(reason);
-    this._clearData();
-    this._lastSendTime = Utils.monotonicNow();
-
-    return new Promise(r =>
-      // If we submit the health ping immediately, the send task would be triggered again
-      // before discarding oversized pings from the queue.
-      // To work around this, we send the ping on the next tick.
-      Services.tm.dispatchToMainThread(() => r(
-        TelemetryController
-          .submitExternalPing(this.HEALTH_PING_TYPE, payload, {addClientId: true}))));
-  },
-
-  /**
-   * Accumulate failure information and trigger a ping immediately or on timeout.
-   * @param {String} failureType The type of failure (e.g. "timeout", ...).
-   * @param {String} failureSubType The subtype of failure (e.g. ping type, ...).
-   * @returns {Promise} Test-only, resolved when the ping is stored or sent.
-   */
-  _addToFailure(failureType, failureSubType) {
-    this._log.trace("_addToFailure() - with type and subtype: " + failureType + " : " + failureSubType);
-
-    if (!(failureType in this._failures)) {
-      this._failures[failureType] = {};
-    }
-
-    let current = this._failures[failureType][failureSubType] || 0;
-    this._failures[failureType][failureSubType] = current + 1;
-
-    const now = Utils.monotonicNow();
-    if ((now - this._lastSendTime) >= SEND_TICK_DELAY) {
-      return this._submitPing(this.Reason.IMMEDIATE);
-    }
-
-    let submissionDelay = SEND_TICK_DELAY - now - this._lastSendTime;
-    this._timeoutId =
-      Policy.setSchedulerTickTimeout(() => TelemetryHealthPing._submitPing(this.Reason.DELAYED), submissionDelay);
-    return Promise.resolve();
-  },
-
-  /**
-   * @returns {boolean} Check the availability of recorded failures data.
-   */
-  _hasDataToSend() {
-    return Object.keys(this._failures).length !== 0;
-  },
-
-  /**
-   * Clear recorded failures data.
-   */
-  _clearData() {
-    this._log.trace("_clearData()");
-    this._failures = {};
-  },
-
-  /**
-   * Clear and reset timeout.
-   */
-  _resetTimeout() {
-    if (this._timeoutId) {
-      Policy.clearSchedulerTickTimeout(this._timeoutId);
-      this._timeoutId = null;
-    }
-  },
-
-  /**
-   * Submit latest ping on shutdown.
-   * @returns {Promise} Test-only, resolved when the ping is stored or sent.
-   */
-  shutdown() {
-    this._log.trace("shutdown()");
-    this._resetTimeout();
-    return this._submitPing(this.Reason.SHUT_DOWN);
-  },
-
-  /**
-   * Test-only, restore to initial state.
-   */
-  testReset() {
-    this._lastSendTime = -SEND_TICK_DELAY;
-    this._clearData();
-    this._resetTimeout();
-  },
-
-  get _log() {
-    if (!this._logger) {
-      this._logger = Log.repository.getLoggerWithMessagePrefix(LOGGER_NAME, LOGGER_PREFIX + "::");
-    }
-
-    return this._logger;
-  },
-};
--- a/toolkit/components/telemetry/TelemetrySend.jsm
+++ b/toolkit/components/telemetry/TelemetrySend.jsm
@@ -34,19 +34,16 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource://gre/modules/TelemetryStorage.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetryReportingPolicy",
                                   "resource://gre/modules/TelemetryReportingPolicy.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "OS",
                                   "resource://gre/modules/osfile.jsm");
 XPCOMUtils.defineLazyServiceGetter(this, "Telemetry",
                                    "@mozilla.org/base/telemetry;1",
                                    "nsITelemetry");
-XPCOMUtils.defineLazyModuleGetter(this, "TelemetryHealthPing",
-                                  "resource://gre/modules/TelemetryHealthPing.jsm");
-
 
 const Utils = TelemetryUtils;
 
 const LOGGER_NAME = "Toolkit.Telemetry";
 const LOGGER_PREFIX = "TelemetrySend::";
 
 const TOPIC_IDLE_DAILY = "idle-daily";
 // The following topics are notified when Firefox is closing
@@ -93,16 +90,25 @@ const OVERDUE_PING_FILE_AGE = 7 * 24 * 6
 const XHR_ERROR_TYPE = [
   "eOK",
   "eRequest",
   "eUnreachable",
   "eChannelOpen",
   "eRedirect",
 ];
 
+function monotonicNow() {
+  try {
+    return Telemetry.msSinceProcessStart();
+  } catch (ex) {
+    // If this fails fall back to the (non-monotonic) Date value.
+    return Date.now();
+  }
+}
+
 /**
  * This is a policy object used to override behavior within this module.
  * Tests override properties on this object to allow for control of behavior
  * that would otherwise be very hard to cover.
  */
 var Policy = {
   now: () => new Date(),
   midnightPingFuzzingDelay: () => MIDNIGHT_FUZZING_DELAY_MS,
@@ -175,24 +181,16 @@ this.TelemetrySend = {
   get OVERDUE_PING_FILE_AGE() {
     return OVERDUE_PING_FILE_AGE;
   },
 
   get pendingPingCount() {
     return TelemetrySendImpl.pendingPingCount;
   },
 
-  testSetTimeoutForPingSubmit(timeoutInMS) {
-    TelemetrySendImpl._pingSubmissionTimeout = timeoutInMS;
-  },
-
-  testResetTimeOutToDefault() {
-    TelemetrySendImpl._pingSubmissionTimeout = PING_SUBMIT_TIMEOUT_MS;
-  },
-
   /**
    * Partial setup that runs immediately at startup. This currently triggers
    * the crash report annotations.
    */
   earlyInit() {
     TelemetrySendImpl.earlyInit();
   },
 
@@ -589,18 +587,16 @@ var TelemetrySendImpl = {
   _testMode: false,
   // This holds pings that we currently try and haven't persisted yet.
   _currentPings: new Map(),
   // Used to skip spawning the pingsender if OS is shutting down.
   _isOSShutdown: false,
   // Count of pending pings that were overdue.
   _overduePingCount: 0,
 
-  _pingSubmissionTimeout: PING_SUBMIT_TIMEOUT_MS,
-
   OBSERVER_TOPICS: [
     TOPIC_IDLE_DAILY,
     TOPIC_QUIT_APPLICATION_GRANTED,
     TOPIC_QUIT_APPLICATION_FORCED,
   ],
 
   OBSERVED_PREFERENCES: [
     TelemetryUtils.Preferences.TelemetryEnabled,
@@ -1006,17 +1002,17 @@ var TelemetrySendImpl = {
 
   _onPingRequestFinished(success, startTime, id, isPersisted) {
     this._log.trace("_onPingRequestFinished - success: " + success + ", persisted: " + isPersisted);
 
     let sendId = success ? "TELEMETRY_SEND_SUCCESS" : "TELEMETRY_SEND_FAILURE";
     let hsend = Telemetry.getHistogramById(sendId);
     let hsuccess = Telemetry.getHistogramById("TELEMETRY_SUCCESS");
 
-    hsend.add(Utils.monotonicNow() - startTime);
+    hsend.add(monotonicNow() - startTime);
     hsuccess.add(success);
 
     if (!success) {
       // Let the scheduler know about send failures for triggering backoff timeouts.
       SendScheduler.notifySendsFailed();
     }
 
     if (success && isPersisted) {
@@ -1075,29 +1071,29 @@ var TelemetrySendImpl = {
 
     this._log.trace("_doPing - server: " + this._server + ", persisted: " + isPersisted +
                     ", id: " + id);
 
     const url = this._buildSubmissionURL(ping);
 
     let request = new ServiceRequest();
     request.mozBackgroundRequest = true;
-    request.timeout = this._pingSubmissionTimeout;
+    request.timeout = PING_SUBMIT_TIMEOUT_MS;
 
     request.open("POST", url, true);
     request.overrideMimeType("text/plain");
     request.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
     request.setRequestHeader("Date", Policy.now().toUTCString());
 
     this._pendingPingRequests.set(id, request);
 
     // Prevent the request channel from running though URLClassifier (bug 1296802)
     request.channel.loadFlags &= ~Ci.nsIChannel.LOAD_CLASSIFY_URI;
 
-    const monotonicStartTime = Utils.monotonicNow();
+    const monotonicStartTime = monotonicNow();
     let deferred = PromiseUtils.defer();
 
     let onRequestFinished = (success, event) => {
       let onCompletion = () => {
         if (success) {
           let histogram = Telemetry.getHistogramById("TELEMETRY_SUCCESSFUL_SEND_PINGS_SIZE_KB");
           histogram.add(compressedPingSizeKB);
           deferred.resolve();
@@ -1117,18 +1113,16 @@ var TelemetrySendImpl = {
               });
     };
 
     let errorhandler = (event) => {
       let failure = event.type;
       if (failure === "error") {
         failure = XHR_ERROR_TYPE[request.errorCode];
       }
-
-      TelemetryHealthPing.recordSendFailure(failure);
       Telemetry.getHistogramById("TELEMETRY_SEND_FAILURE_TYPE").add(failure);
 
       this._log.error("_doPing - error making request to " + url + ": " + failure);
       onRequestFinished(false, event);
     };
     request.onerror = errorhandler;
     request.ontimeout = errorhandler;
     request.onabort = errorhandler;
@@ -1164,42 +1158,40 @@ var TelemetrySendImpl = {
     };
 
     // If that's a legacy ping format, just send its payload.
     let networkPayload = isV4PingFormat(ping) ? ping : ping.payload;
     request.setRequestHeader("Content-Encoding", "gzip");
     let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
                     .createInstance(Ci.nsIScriptableUnicodeConverter);
     converter.charset = "UTF-8";
-    let startTime = Utils.monotonicNow();
+    let startTime = monotonicNow();
     let utf8Payload = converter.ConvertFromUnicode(JSON.stringify(networkPayload));
     utf8Payload += converter.Finish();
-    Telemetry.getHistogramById("TELEMETRY_STRINGIFY").add(Utils.monotonicNow() - startTime);
+    Telemetry.getHistogramById("TELEMETRY_STRINGIFY").add(monotonicNow() - startTime);
 
     // 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);
       Telemetry.getHistogramById("TELEMETRY_PING_SIZE_EXCEEDED_SEND").add();
       Telemetry.getHistogramById("TELEMETRY_DISCARDED_SEND_PINGS_SIZE_MB")
                .add(Math.floor(pingSizeBytes / 1024 / 1024));
       // We don't need to call |request.abort()| as it was not sent yet.
       this._pendingPingRequests.delete(id);
-
-      TelemetryHealthPing.recordDiscardedPing(ping.type);
       return TelemetryStorage.removePendingPing(id);
     }
 
     let payloadStream = Cc["@mozilla.org/io/string-input-stream;1"]
                         .createInstance(Ci.nsIStringInputStream);
-    startTime = Utils.monotonicNow();
+    startTime = monotonicNow();
     payloadStream.data = gzipCompressString(utf8Payload);
 
     const compressedPingSizeKB = Math.floor(payloadStream.data.length / 1024);
-    Telemetry.getHistogramById("TELEMETRY_COMPRESS").add(Utils.monotonicNow() - startTime);
+    Telemetry.getHistogramById("TELEMETRY_COMPRESS").add(monotonicNow() - startTime);
     request.send(payloadStream);
 
     return deferred.promise;
   },
 
   /**
    * Check if sending is temporarily disabled.
    * @return {Boolean} True if we can send pings to the server right now, false if
--- a/toolkit/components/telemetry/TelemetryUtils.jsm
+++ b/toolkit/components/telemetry/TelemetryUtils.jsm
@@ -6,17 +6,16 @@
 
 this.EXPORTED_SYMBOLS = [
   "TelemetryUtils"
 ];
 
 const {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/Preferences.jsm", this);
-Cu.import("resource://gre/modules/Services.jsm", this);
 
 const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
 
 const PREF_TELEMETRY_ENABLED = "toolkit.telemetry.enabled";
 
 const IS_CONTENT_PROCESS = (function() {
   // We cannot use Services.appinfo here because in telemetry xpcshell tests,
   // appinfo is initially unavailable, and becomes available only later on.
@@ -179,21 +178,9 @@ this.TelemetryUtils = {
       + "-" + padNumber(date.getDate(), 2)
       + "T" + padNumber(date.getHours(), 2)
       + ":" + padNumber(date.getMinutes(), 2)
       + ":" + padNumber(date.getSeconds(), 2)
       + "." + date.getMilliseconds()
       + sign(tzOffset) + padNumber(Math.floor(Math.abs(tzOffset / 60)), 2)
       + ":" + padNumber(Math.abs(tzOffset % 60), 2);
   },
-
-  /**
-   * @returns {number} The monotonic time since the process start
-   * or (non-monotonic) Date value if this fails back.
-   */
-  monotonicNow() {
-    try {
-      return Services.telemetry.msSinceProcessStart();
-    } catch (ex) {
-      return Date.now();
-    }
-  }
 };
--- a/toolkit/components/telemetry/docs/internals/preferences.rst
+++ b/toolkit/components/telemetry/docs/internals/preferences.rst
@@ -132,12 +132,8 @@ The following prefs are for testing purp
 
 ``toolkit.telemetry.modulesPing.interval``
 
   Interval between "modules" ping transmissions.
 
 ``toolkit.telemetry.send.overrideOfficialCheck``
 
   If true, allows sending pings on unofficial builds. Requires a restart.
-
-``toolkit.telemetry.healthping.enabled``
-
-  If false, sending health pings is disabled. Defaults to true.
--- a/toolkit/components/telemetry/moz.build
+++ b/toolkit/components/telemetry/moz.build
@@ -79,17 +79,16 @@ EXTRA_COMPONENTS += [
     'TelemetryStartup.manifest'
 ]
 
 EXTRA_JS_MODULES += [
     'GCTelemetry.jsm',
     'TelemetryArchive.jsm',
     'TelemetryController.jsm',
     'TelemetryEnvironment.jsm',
-    'TelemetryHealthPing.jsm',
     'TelemetryLog.jsm',
     'TelemetryModules.jsm',
     'TelemetryReportingPolicy.jsm',
     'TelemetrySend.jsm',
     'TelemetrySession.jsm',
     'TelemetryStopwatch.jsm',
     'TelemetryStorage.jsm',
     'TelemetryTimestamps.jsm',
--- a/toolkit/components/telemetry/tests/unit/head.js
+++ b/toolkit/components/telemetry/tests/unit/head.js
@@ -296,20 +296,16 @@ function setEmptyPrefWatchlist() {
   let TelemetryEnvironment =
     Cu.import("resource://gre/modules/TelemetryEnvironment.jsm").TelemetryEnvironment;
   return TelemetryEnvironment.onInitialized().then(() => {
     TelemetryEnvironment.testWatchPreferences(new Map());
 
   });
 }
 
-function histogramValueCount(histogramSnapshot) {
-  return histogramSnapshot.counts.reduce((a, b) => a + b);
-}
-
 if (runningInParent) {
   // Set logging preferences for all the tests.
   Services.prefs.setCharPref("toolkit.telemetry.log.level", "Trace");
   // Telemetry archiving should be on.
   Services.prefs.setBoolPref(TelemetryUtils.Preferences.ArchiveEnabled, true);
   // Telemetry xpcshell tests cannot show the infobar.
   Services.prefs.setBoolPref(TelemetryUtils.Preferences.BypassNotification, true);
   // FHR uploads should be enabled.
--- a/toolkit/components/telemetry/tests/unit/test_PingAPI.js
+++ b/toolkit/components/telemetry/tests/unit/test_PingAPI.js
@@ -12,19 +12,16 @@ Cu.import("resource://gre/modules/Teleme
 Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
 Cu.import("resource://gre/modules/osfile.jsm", this);
 Cu.import("resource://gre/modules/Services.jsm", this);
 
 XPCOMUtils.defineLazyGetter(this, "gPingsArchivePath", function() {
   return OS.Path.join(OS.Constants.Path.profileDir, "datareporting", "archived");
 });
 
-XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
-  "resource://gre/modules/Preferences.jsm");
-
 /**
  * Fakes the archive storage quota.
  * @param {Integer} aArchiveQuota The new quota, in bytes.
  */
 function fakeStorageQuota(aArchiveQuota) {
   let storage = Cu.import("resource://gre/modules/TelemetryStorage.jsm", {});
   storage.Policy.getArchiveQuota = () => aArchiveQuota;
 }
@@ -67,17 +64,16 @@ var getArchivedPingsInfo = async functio
   return archivedPings;
 };
 
 add_task(async function test_setup() {
   do_get_profile(true);
   // Make sure we don't generate unexpected pings due to pref changes.
   await setEmptyPrefWatchlist();
   Services.prefs.setBoolPref(TelemetryUtils.Preferences.TelemetryEnabled, true);
-  Preferences.set("toolkit.telemetry.healthping.enabled", false);
 });
 
 add_task(async function test_archivedPings() {
   // TelemetryController should not be fully initialized at this point.
   // Submitting pings should still work fine.
 
   const PINGS = [
     {
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryController_idle.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryController_idle.js
@@ -5,29 +5,27 @@
 
 Cu.import("resource://testing-common/httpd.js", this);
 Cu.import("resource://gre/modules/PromiseUtils.jsm", this);
 Cu.import("resource://gre/modules/Services.jsm", this);
 Cu.import("resource://gre/modules/TelemetryStorage.jsm", this);
 Cu.import("resource://gre/modules/TelemetryController.jsm", this);
 Cu.import("resource://gre/modules/TelemetrySession.jsm", this);
 Cu.import("resource://gre/modules/TelemetrySend.jsm", this);
-Cu.import("resource://gre/modules/Preferences.jsm", this);
 
 var gHttpServer = null;
 
 add_task(async function test_setup() {
   do_get_profile();
 
   // Make sure we don't generate unexpected pings due to pref changes.
   await setEmptyPrefWatchlist();
 
   Services.prefs.setBoolPref(TelemetryUtils.Preferences.TelemetryEnabled, true);
   Services.prefs.setBoolPref(TelemetryUtils.Preferences.FhrUploadEnabled, true);
-  Preferences.set("toolkit.telemetry.healthping.enabled", false);
 
   // Start the webserver to check if the pending ping correctly arrives.
   gHttpServer = new HttpServer();
   gHttpServer.start(-1);
 });
 
 add_task(async function testSendPendingOnIdleDaily() {
   // Create a valid pending ping.
deleted file mode 100644
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryHealthPing.js
+++ /dev/null
@@ -1,184 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// This tests the public Telemetry API for submitting Health pings.
-
-"use strict";
-
-Cu.import("resource://gre/modules/TelemetryController.jsm", this);
-Cu.import("resource://gre/modules/TelemetryHealthPing.jsm", this);
-Cu.import("resource://gre/modules/TelemetryStorage.jsm", this);
-Cu.import("resource://gre/modules/TelemetryUtils.jsm", this);
-Cu.import("resource://gre/modules/Preferences.jsm", this);
-
-const Utils = TelemetryUtils;
-
-function checkHealthPingStructure(ping, expectedFailuresDict) {
-  let payload = ping.payload;
-  Assert.equal(ping.type, TelemetryHealthPing.HEALTH_PING_TYPE, "Should have recorded a health ping.");
-
-  for (let [key, value] of Object.entries(expectedFailuresDict)) {
-    Assert.deepEqual(payload[key], value, "Should have recorded correct entry with key: " + key);
-  }
-}
-
-function fakeHealthSchedulerTimer(set, clear) {
-  let telemetryHealthPing = Cu.import("resource://gre/modules/TelemetryHealthPing.jsm", {});
-  telemetryHealthPing.Policy.setSchedulerTickTimeout = set;
-  telemetryHealthPing.Policy.clearSchedulerTickTimeout = clear;
-}
-
-add_task(async function setup() {
-  // Trigger a proper telemetry init.
-  do_get_profile(true);
-  // Make sure we don't generate unexpected pings due to pref changes.
-  await setEmptyPrefWatchlist();
-  Services.prefs.setBoolPref("toolkit.telemetry.enabled", true);
-
-  await TelemetryController.testSetup();
-  PingServer.start();
-  TelemetrySend.setServer("http://localhost:" + PingServer.port);
-  Preferences.set(TelemetryController.Constants.PREF_SERVER,
-    "http://localhost:" + PingServer.port);
-});
-
-add_task(async function test_sendImmediately() {
-  PingServer.clearRequests();
-  TelemetryHealthPing.testReset();
-
-  await TelemetryHealthPing.recordSendFailure("testProblem");
-  let ping = await PingServer.promiseNextPing();
-  checkHealthPingStructure(ping, {
-    [TelemetryHealthPing.FailureType.SEND_FAILURE]: {
-      "testProblem": 1
-    },
-    "os": TelemetryHealthPing.OsInfo,
-    "reason": TelemetryHealthPing.Reason.IMMEDIATE
-  });
-});
-
-add_task(async function test_sendOnDelay() {
-  PingServer.clearRequests();
-  TelemetryHealthPing.testReset();
-
-  // This first failure should immediately trigger a ping. After this, subsequent failures should be throttled.
-  await TelemetryHealthPing.recordSendFailure("testFailure");
-  let testPing = await PingServer.promiseNextPing();
-  Assert.equal(testPing.type, TelemetryHealthPing.HEALTH_PING_TYPE, "Should have recorded a health ping.");
-
-  // Retrieve delayed call back.
-  let pingSubmissionCallBack = null;
-  fakeHealthSchedulerTimer((callBack) => pingSubmissionCallBack = callBack, () => {});
-
-  // Record two failures, health ping must not be send now.
-  await TelemetryHealthPing.recordSendFailure("testFailure");
-  await TelemetryHealthPing.recordSendFailure("testFailure");
-
-  // Wait for sending delayed health ping.
-  await pingSubmissionCallBack();
-
-  let ping = await PingServer.promiseNextPing();
-  checkHealthPingStructure(ping, {
-    [TelemetryHealthPing.FailureType.SEND_FAILURE]: {
-      "testFailure": 2
-    },
-    "os": TelemetryHealthPing.OsInfo,
-    "reason": TelemetryHealthPing.Reason.DELAYED
-  });
-});
-
-add_task(async function test_sendOverSizedPing() {
-  TelemetryHealthPing.testReset();
-  PingServer.clearRequests();
-  let OVER_SIZED_PING_TYPE = "over-sized-ping";
-  let overSizedData = generateRandomString(2 * 1024 * 1024);
-
-  await TelemetryController.submitExternalPing(OVER_SIZED_PING_TYPE, {"data": overSizedData});
-  let ping = await PingServer.promiseNextPing();
-
-  checkHealthPingStructure(ping, {
-    [TelemetryHealthPing.FailureType.DISCARDED_FOR_SIZE]: {
-      [OVER_SIZED_PING_TYPE]: 1
-    },
-    "os": TelemetryHealthPing.OsInfo,
-    "reason": TelemetryHealthPing.Reason.IMMEDIATE
-  });
-});
-
-add_task(async function test_sendOnTimeout() {
-  TelemetryHealthPing.testReset();
-  PingServer.clearRequests();
-  let PING_TYPE = "ping-on-timeout";
-
-  // Set up small ping submission timeout to always have timeout error.
-  TelemetrySend.testSetTimeoutForPingSubmit(2);
-
-  // Reset the timeout after receiving the first ping to be able to send health ping.
-  PingServer.registerPingHandler((request, result) => {
-    PingServer.resetPingHandler();
-    TelemetrySend.testResetTimeOutToDefault();
-  });
-
-  await TelemetryController.submitExternalPing(PING_TYPE, {});
-  let ping = await PingServer.promiseNextPing();
-  checkHealthPingStructure(ping, {
-    [TelemetryHealthPing.FailureType.SEND_FAILURE]: {
-      "timeout": 1
-    },
-    "os": TelemetryHealthPing.OsInfo,
-    "reason": TelemetryHealthPing.Reason.IMMEDIATE
-  });
-
-  // Clear pending pings to avoid resending pings which fail with time out error.
-  await TelemetryStorage.testClearPendingPings();
-});
-
-add_task(async function test_sendOnlyTopTenDiscardedPings() {
-  TelemetryHealthPing.testReset();
-  PingServer.clearRequests();
-  let PING_TYPE = "sort-discarded";
-
-  // This first failure should immediately trigger a ping. After this, subsequent failures should be throttled.
-  await TelemetryHealthPing.recordSendFailure("testFailure");
-  let testPing = await PingServer.promiseNextPing();
-  Assert.equal(testPing.type, TelemetryHealthPing.HEALTH_PING_TYPE, "Should have recorded a health ping.");
-
-
-  // Retrieve delayed call back.
-  let pingSubmissionCallBack = null;
-  fakeHealthSchedulerTimer((callBack) => pingSubmissionCallBack = callBack, () => {});
-
-  // Add failures
-  for (let i = 1; i < 12; i++) {
-    for (let j = 1; j < i; j++) {
-      await TelemetryHealthPing.recordDiscardedPing(PING_TYPE + i);
-    }
-  }
-
-  await pingSubmissionCallBack();
-  let ping = await PingServer.promiseNextPing();
-
-  checkHealthPingStructure(ping, {
-    "os": TelemetryHealthPing.OsInfo,
-    "reason": TelemetryHealthPing.Reason.DELAYED,
-    [TelemetryHealthPing.FailureType.DISCARDED_FOR_SIZE]: {
-      [PING_TYPE + 11]: 10,
-      [PING_TYPE + 10]: 9,
-      [PING_TYPE + 9]: 8,
-      [PING_TYPE + 8]: 7,
-      [PING_TYPE + 7]: 6,
-      [PING_TYPE + 6]: 5,
-      [PING_TYPE + 5]: 4,
-      [PING_TYPE + 4]: 3,
-      [PING_TYPE + 3]: 2,
-      [PING_TYPE + 2]: 1
-    }
-  });
-});
-
-add_task(async function cleanup() {
-  await PingServer.stop();
-});
-
-
--- a/toolkit/components/telemetry/tests/unit/test_TelemetrySend.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetrySend.js
@@ -1,17 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/
 */
 
 // This tests the public Telemetry API for submitting pings.
 
 "use strict";
 
-Cu.import("resource://gre/modules/TelemetryHealthPing.jsm", this);
 Cu.import("resource://gre/modules/TelemetryController.jsm", this);
 Cu.import("resource://testing-common/ContentTaskUtils.jsm", this);
 Cu.import("resource://gre/modules/TelemetrySession.jsm", this);
 Cu.import("resource://gre/modules/TelemetrySend.jsm", this);
 Cu.import("resource://gre/modules/TelemetryStorage.jsm", this);
 Cu.import("resource://gre/modules/TelemetryUtils.jsm", this);
 Cu.import("resource://gre/modules/Services.jsm", this);
 Cu.import("resource://gre/modules/Preferences.jsm", this);
@@ -65,16 +64,20 @@ var checkPingsSaved = async function(pin
       dump("checkPingsSaved - failed to find ping: " + path + "\n");
       allFound = false;
     }
   }
 
   return allFound;
 };
 
+function histogramValueCount(h) {
+  return h.counts.reduce((a, b) => a + b);
+}
+
 add_task(async function test_setup() {
   // Trigger a proper telemetry init.
   do_get_profile(true);
   // Make sure we don't generate unexpected pings due to pref changes.
   await setEmptyPrefWatchlist();
   Services.prefs.setBoolPref(TelemetryUtils.Preferences.TelemetryEnabled, true);
 });
 
@@ -318,41 +321,34 @@ add_task(async function test_discardBigP
   }
 
   // Generate a 2MB string and create an oversized payload.
   const OVERSIZED_PAYLOAD = {"data": generateRandomString(2 * 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" });
   await TelemetrySend.testWaitOnOutgoingPings();
-  await PingServer.promiseNextPing();
 
   Assert.equal(histSizeExceeded.snapshot().sum, 0, "Telemetry must report no oversized ping submitted.");
   Assert.equal(histDiscardedSize.snapshot().sum, 0, "Telemetry must report no oversized pings.");
   Assert.deepEqual(histSuccess.snapshot().counts, [0, 1, 0], "Should have recorded sending success.");
   Assert.equal(histogramValueCount(histSendTimeSuccess.snapshot()), 1, "Should have recorded send success time.");
   Assert.greater(histSendTimeSuccess.snapshot().sum, 0, "Should have recorded send success time.");
   Assert.equal(histogramValueCount(histSendTimeFail.snapshot()), 0, "Should not have recorded send failure time.");
 
   // Submit an oversized ping and check that it gets discarded.
-  TelemetryHealthPing.testReset();
   await TelemetryController.submitExternalPing(TEST_PING_TYPE, OVERSIZED_PAYLOAD);
-  let ping = await PingServer.promiseNextPing();
+  await TelemetrySend.testWaitOnOutgoingPings();
 
   Assert.equal(histSizeExceeded.snapshot().sum, 1, "Telemetry must report 1 oversized ping submitted.");
   Assert.equal(histDiscardedSize.snapshot().counts[2], 1, "Telemetry must report a 2MB, oversized, ping submitted.");
-  Assert.deepEqual(histSuccess.snapshot().counts, [0, 2, 0], "Should have recorded sending success.");
-  Assert.equal(histogramValueCount(histSendTimeSuccess.snapshot()), 2, "Should have recorded send success time.");
+  Assert.deepEqual(histSuccess.snapshot().counts, [0, 1, 0], "Should have recorded sending success.");
+  Assert.equal(histogramValueCount(histSendTimeSuccess.snapshot()), 1, "Should have recorded send success time.");
   Assert.greater(histSendTimeSuccess.snapshot().sum, 0, "Should have recorded send success time.");
   Assert.equal(histogramValueCount(histSendTimeFail.snapshot()), 0, "Should not have recorded send failure time.");
-
-  Assert.equal(ping.type, TelemetryHealthPing.HEALTH_PING_TYPE, "Should have received a health ping.");
-  Assert.deepEqual(ping.payload[TelemetryHealthPing.FailureType.DISCARDED_FOR_SIZE],
-    { [TEST_PING_TYPE]: 1 }, "Should have recorded correct type of oversized ping.");
-  Assert.deepEqual(ping.payload["os"], TelemetryHealthPing.OsInfo, "Should have correct os info.")
 });
 
 add_task(async function test_evictedOnServerErrors() {
   const TEST_TYPE = "test-evicted";
 
   await TelemetrySend.reset();
 
   let histEvicted = Telemetry.getHistogramById("TELEMETRY_PING_EVICTED_FOR_SERVER_ERRORS");
@@ -509,11 +505,12 @@ add_task(async function test_measurePing
 
   // Check that we recorded the ping sizes correctly into histograms.
   Assert.equal(histogramValueCount(histSuccessPingSize.snapshot()), 2,
     "Should have recorded 2 successful ping into histogram.");
   Assert.equal(histogramValueCount(histFailedPingSize.snapshot()), 1,
     "Should have recorded 1 failed ping into histogram.");
 });
 
+
 add_task(async function cleanup() {
   await PingServer.stop();
 });
--- a/toolkit/components/telemetry/tests/unit/xpcshell.ini
+++ b/toolkit/components/telemetry/tests/unit/xpcshell.ini
@@ -34,17 +34,16 @@ skip-if = os == "android"
 tags = addons
 [test_PingAPI.js]
 skip-if = os == "android"
 [test_TelemetryFlagClear.js]
 [test_TelemetryLateWrites.js]
 [test_TelemetryLockCount.js]
 [test_TelemetryLog.js]
 [test_TelemetryController.js]
-[test_TelemetryHealthPing.js]
 tags = addons
 [test_TelemetryController_idle.js]
 [test_TelemetryControllerShutdown.js]
 tags = addons
 [test_TelemetryStopwatch.js]
 [test_TelemetryControllerBuildID.js]
 [test_TelemetrySendOldPings.js]
 skip-if = os == "android" # Disabled due to intermittent orange on Android