Bug 1526895 - Calculate process creation timestamp once r=chutten
authorJan-Erik Rediger <jrediger@mozilla.com>
Mon, 11 Feb 2019 14:39:57 +0000
changeset 458746 74bd0fed9dbe
parent 458745 4cf8e31cb261
child 458747 734770da29fd
push id35548
push useropoprus@mozilla.com
push dateWed, 13 Feb 2019 09:48:26 +0000
treeherdermozilla-central@93e37c529818 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1526895
milestone67.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 1526895 - Calculate process creation timestamp once r=chutten Differential Revision: https://phabricator.services.mozilla.com/D19358
toolkit/components/telemetry/pings/EventPing.jsm
--- a/toolkit/components/telemetry/pings/EventPing.jsm
+++ b/toolkit/components/telemetry/pings/EventPing.jsm
@@ -60,26 +60,32 @@ var TelemetryEventPing = {
 
   _logger: null,
 
   _testing: false,
 
   // So that if we quickly reach the max limit we can immediately send.
   _lastSendTime: -DEFAULT_MIN_FREQUENCY_MS,
 
+  _processStartTimestamp: 0,
+
   get dataset() {
     return Telemetry.canRecordPrereleaseData ? Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN
                                              : Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT;
   },
 
   startup() {
     if (!Services.prefs.getBoolPref(Utils.Preferences.EventPingEnabled, true)) {
       return;
     }
     this._log.trace("Starting up.");
+
+    // Calculate process creation once.
+    this._processStartTimestamp = Math.round((Date.now() - TelemetryUtils.monotonicNow()) / MS_IN_A_MINUTE) * MS_IN_A_MINUTE;
+
     Services.obs.addObserver(this, EVENT_LIMIT_REACHED_TOPIC);
 
     XPCOMUtils.defineLazyPreferenceGetter(this, "maxEventsPerPing",
                                           Utils.Preferences.EventPingEventLimit,
                                           DEFAULT_EVENT_LIMIT);
     XPCOMUtils.defineLazyPreferenceGetter(this, "maxFrequency",
                                           Utils.Preferences.EventPingMaximumFrequency,
                                           DEFAULT_MAX_FREQUENCY_MS);
@@ -160,21 +166,19 @@ var TelemetryEventPing = {
       // Don't send a ping if we haven't any events.
       this._log.trace("not sending event ping due to lack of events");
       return;
     }
 
     // The reason doesn't matter as it will just be echo'd back.
     let sessionMeta = TelemetrySession.getMetadata(reason);
 
-    let processStartTimestamp = Math.round((Date.now() - TelemetryUtils.monotonicNow()) / MS_IN_A_MINUTE) * MS_IN_A_MINUTE;
-
     let payload = {
       reason,
-      processStartTimestamp,
+      processStartTimestamp: this._processStartTimestamp,
       sessionId: sessionMeta.sessionId,
       subsessionId: sessionMeta.subsessionId,
       lostEventsCount: 0,
       events: snapshot,
     };
 
     if (discardLeftovers) {
       // Any leftovers must be discarded, the count submitted in the ping.