From 90250f00693358bf25b9531b58a2cfd6f0f71409 Mon Sep 17 00:00:00 2001 From: Georg Fritzsche Date: Tue, 28 Jul 2015 18:05:35 +0200 Subject: [PATCH] Bug 1187339 - Always duplicate-save new main pings as aborted-session pings. r=dexter --- .../components/telemetry/TelemetrySession.jsm | 43 +++++++------------ 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/toolkit/components/telemetry/TelemetrySession.jsm b/toolkit/components/telemetry/TelemetrySession.jsm index dc18999474d1..ecb9412ee753 100644 --- a/toolkit/components/telemetry/TelemetrySession.jsm +++ b/toolkit/components/telemetry/TelemetrySession.jsm @@ -531,32 +531,20 @@ let TelemetryScheduler = { } this._lastTickTime = now; - // Check if aborted-session ping is due. - let isAbortedPingDue = - (now - this._lastSessionCheckpointTime) >= ABORTED_SESSION_UPDATE_INTERVAL_MS; - // Check if daily ping is due. - let shouldSendDaily = this._isDailyPingDue(nowDate); - // We can combine the daily-ping and the aborted-session ping in the following cases: - // - If both the daily and the aborted session pings are due (a laptop that wakes - // up after a few hours). - // - If either the daily ping is due and the other one would follow up shortly - // (whithin the coalescence threshold). - let nextSessionCheckpoint = - this._lastSessionCheckpointTime + ABORTED_SESSION_UPDATE_INTERVAL_MS; - let combineActions = (shouldSendDaily && isAbortedPingDue) || (shouldSendDaily && - Utils.areTimesClose(now, nextSessionCheckpoint, - SCHEDULER_COALESCE_THRESHOLD_MS)); + // Check if the daily ping is due. + const shouldSendDaily = this._isDailyPingDue(nowDate); - if (combineActions) { - this._log.trace("_schedulerTickLogic - Combining pings."); - // Send the daily ping and also save its payload as an aborted-session ping. - return Impl._sendDailyPing(true).then(() => this._dailyPingSucceeded(now), - () => this._dailyPingFailed(now)); - } else if (shouldSendDaily) { + if (shouldSendDaily) { this._log.trace("_schedulerTickLogic - Daily ping due."); return Impl._sendDailyPing().then(() => this._dailyPingSucceeded(now), () => this._dailyPingFailed(now)); - } else if (isAbortedPingDue) { + } + + // Check if the aborted-session ping is due. If a daily ping was saved above, it was + // already duplicated as an aborted-session ping. + const isAbortedPingDue = + (now - this._lastSessionCheckpointTime) >= ABORTED_SESSION_UPDATE_INTERVAL_MS; + if (isAbortedPingDue) { this._log.trace("_schedulerTickLogic - Aborted session ping due."); return this._saveAbortedPing(now); } @@ -1871,11 +1859,9 @@ let Impl = { /** * Gather and send a daily ping. - * @param {Boolean} [saveAsAborted=false] Also saves the payload as an aborted-session - * ping. * @return {Promise} Resolved when the ping is sent. */ - _sendDailyPing: function(saveAsAborted = false) { + _sendDailyPing: function() { this._log.trace("_sendDailyPing"); let payload = this.getSessionPayload(REASON_DAILY, true); @@ -1885,11 +1871,14 @@ let Impl = { }; let promise = TelemetryController.submitExternalPing(getPingType(payload), payload, options); - // If required, also save the payload as an aborted session. - if (saveAsAborted && IS_UNIFIED_TELEMETRY) { + + // Also save the payload as an aborted session. If we delay this, aborted-session can + // lag behind for the profileSubsessionCounter and other state, complicating analysis. + if (IS_UNIFIED_TELEMETRY) { let abortedPromise = this._saveAbortedSessionPing(payload); promise = promise.then(() => abortedPromise); } + return promise; },