Bug 1619990 - Always load dynamic-builtin probes in xpcshell test environment. r=chutten,gbrown

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan-Erik Rediger 2020-03-10 19:37:36 +00:00
Родитель a415028a3c
Коммит 0819017624
2 изменённых файлов: 41 добавлений и 0 удалений

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

@ -1616,6 +1616,36 @@ try {
do_throw(e);
}
/**
* Changing/Adding scalars or events to Telemetry is supported in build-faster/artifacts builds.
* These need to be loaded explicitly at start.
* It usually happens once all of Telemetry is initialized and set up.
* However in xpcshell tests Telemetry is not necessarily fully loaded,
* so we help out users by loading at least the dynamic-builtin probes.
*/
try {
let _AppConstants = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm",
null
).AppConstants;
// We only need to run this in the parent process.
// We only want to run this for local developer builds (which should have a "default" update channel).
if (runningInParent && _AppConstants.MOZ_UPDATE_CHANNEL == "default") {
let _TelemetryController = ChromeUtils.import(
"resource://gre/modules/TelemetryController.jsm",
null
).TelemetryController;
let complete = false;
let doComplete = () => (complete = true);
_TelemetryController.testRegisterJsProbes().then(doComplete, doComplete);
_Services.tm.spinEventLoopUntil(() => complete);
}
} catch (e) {
do_throw(e);
}
function _load_mozinfo() {
let mozinfoFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
mozinfoFile.initWithPath(_MOZINFO_JS_PATH);

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

@ -173,6 +173,17 @@ var TelemetryController = Object.freeze({
return Promise.resolve(Impl._probeRegistrationPromise);
},
/**
* Register 'dynamic builtin' probes from the JSON definition files.
* This is needed to support adding new probes in developer builds
* without rebuilding the whole codebase.
*
* This is not meant to be used outside of local developer builds.
*/
testRegisterJsProbes() {
return Impl.registerJsProbes();
},
/**
* Used only for testing purposes.
*/