Bug 1514392 - Use fallback process start time, even if inconsistent r=wlach,chutten

Differential Revision: https://phabricator.services.mozilla.com/D19645

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan-Erik Rediger 2019-02-14 16:02:12 +00:00
Родитель bc15820709
Коммит c9edc914a9
5 изменённых файлов: 26 добавлений и 24 удалений

Просмотреть файл

@ -1806,6 +1806,20 @@ telemetry:
record_in_processes:
- 'main'
process_creation_timestamp_inconsistent:
bug_numbers:
- 1514392
description: >
The number of times ProcessCreation saw an inconsistent value.
expires: "72"
kind: uint
notification_emails:
- jrediger@mozilla.com
release_channel_collection: opt-out
record_in_processes:
- 'main'
- 'content'
telemetry.discarded:
accumulations:
bug_numbers:

Просмотреть файл

@ -217,11 +217,7 @@ var TelemetryUtils = {
* or (non-monotonic) Date value if this fails back.
*/
monotonicNow() {
try {
return Services.telemetry.msSinceProcessStart();
} catch (ex) {
return Date.now();
}
return Services.telemetry.msSinceProcessStart();
},
/**

Просмотреть файл

@ -14,6 +14,7 @@
#include "nsThreadUtils.h"
#include "nsVersionComparator.h"
#include "TelemetryProcessData.h"
#include "Telemetry.h"
namespace mozilla {
namespace Telemetry {
@ -83,11 +84,15 @@ bool CanRecordProduct(SupportedProduct aProducts) {
}
nsresult MsSinceProcessStart(double* aResult) {
bool error;
*aResult = (TimeStamp::NowLoRes() - TimeStamp::ProcessCreation(&error))
.ToMilliseconds();
if (error) {
return NS_ERROR_NOT_AVAILABLE;
bool isInconsistent = false;
*aResult =
(TimeStamp::NowLoRes() - TimeStamp::ProcessCreation(&isInconsistent))
.ToMilliseconds();
if (isInconsistent) {
Telemetry::ScalarAdd(
Telemetry::ScalarID::TELEMETRY_PROCESS_CREATION_TIMESTAMP_INCONSISTENT,
1);
}
return NS_OK;
}

Просмотреть файл

@ -86,8 +86,6 @@ The length of the current session so far in seconds.
This uses a monotonic clock, so this may mismatch with other measurements that
are not monotonic like calculations based on ``Date.now()``.
If the monotonic clock failed, this will be ``-1``.
Note that this currently does not behave consistently over our supported platforms:
* On Windows this uses ``GetTickCount64()``, which does increase over sleep periods
@ -101,8 +99,6 @@ subsessionLength
The length of this subsession in seconds.
This uses a monotonic clock, so this may mismatch with other measurements that are not monotonic (e.g. based on ``Date.now()``).
If ``sessionLength`` is ``-1``, the monotonic clock is not working.
Also see the remarks for ``sessionLength`` on platform consistency.
processes

Просмотреть файл

@ -88,21 +88,12 @@ function generateUUID() {
return str.substring(1, str.length - 1);
}
function getMsSinceProcessStart() {
try {
return Telemetry.msSinceProcessStart();
} catch (ex) {
// If this fails return a special value.
return -1;
}
}
/**
* This is a policy object used to override behavior for testing.
*/
var Policy = {
now: () => new Date(),
monotonicNow: getMsSinceProcessStart,
monotonicNow: Utils.monotonicNow,
generateSessionUUID: () => generateUUID(),
generateSubsessionUUID: () => generateUUID(),
setSchedulerTickTimeout: (callback, delayMs) => setTimeout(callback, delayMs),