Bug 1205705 - Part 2: Collect client-side fxa-content-server LOADED Telemetry. r=mfinkle,ally p=ally

This collects client-side fxa-content-server data.  The data covers
only the about:accounts experience until:

* the fxa-content-server provides the LOADED message; or
* connection failure is observed.

Nota bene: a healthy fxa-content-server always delivers the LOADED
message!  In future, we might want to timeout the load (and observe
said timeouts) separately.

We collect no data after the fxa-content-server LOADED message.  The
intention is for the server-side metrics flow to capture the valuable
"bounce rate" metrics, since the fxa-content-server team are in
position to quickly improve the web-based UI flow.

The client-side data collected is intended to answer the following
questions:

1) How many remote content loads started;
2) How many loads completed;
3) What proportion of loads made it to the LOADED message, as opposed
to failed;
4) How long it took each successful load to observe the LOADED
message;
5) How long it took each failing load to observe failure.

All of these are keyed by the fxa-content-server endpoint path (like
'settings' or 'profile/avatar'), since I observe differences between
the time-to-LOADED for each endpoint path.

There is a privacy trade-off here.  Mozilla is collecting data to
understand the user experience when about:accounts is connecting to
the specific fxa-content-server hosted by Mozilla at
accounts.firefox.com.  However, we don't want to observe what
alternate servers users might be using, so we can't collect the whole
URL.  Here, we filter the data based on whether the user is /not/
using accounts.firefox.com, and then record just the endpoint path.
Other collected data could expose that the user is using Firefox
Accounts, and together, that leaks the number of users not using
accounts.firefox.com.  We accept this leak: Mozilla already collects
data about whether Sync (both legacy and FxA) is using a custom server
in various situations: see the WEAVE_CUSTOM_* Telemetry histograms.

--HG--
extra : commitid : 6ablpwYytrm
extra : rebase_source : bb04e263adf4fd34d36b51610ca170f3dd9c8328
This commit is contained in:
Nick Alexander 2015-09-18 10:51:39 -04:00
Родитель 543b5c68f0
Коммит 05dd36077b
2 изменённых файлов: 79 добавлений и 4 удалений

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

@ -64,17 +64,60 @@ var loadedDeferred = null;
// We have a new load starting. Replace the existing promise with a new one,
// and queue up the transition to remote content.
function deferTransitionToRemoteAfterLoaded() {
function deferTransitionToRemoteAfterLoaded(url) {
log.d('Waiting for LOADED message.');
// We are collecting data to understand the experience when using
// about:accounts to connect to the specific fxa-content-server hosted by
// Mozilla at accounts.firefox.com. However, we don't want to observe what
// alternate servers users might be using, so we can't collect the whole URL.
// Here, we filter the data based on whether the user is /not/ using
// accounts.firefox.com, and then record just the endpoint path. Other
// collected data could expose that the user is using Firefox Accounts, and
// together, that leaks the number of users not using accounts.firefox.com.
// We accept this leak: Mozilla already collects data about whether Sync (both
// legacy and FxA) is using a custom server in various situations: see the
// WEAVE_CUSTOM_* Telemetry histograms.
let recordResultTelemetry; // Defined only when not customized.
let isCustomized = Services.prefs.prefHasUserValue("identity.fxaccounts.remote.webchannel.uri");
if (!isCustomized) {
// Turn "https://accounts.firefox.com/settings?context=fx_fennec_v1&email=EMAIL" into "/settings".
let key = Services.io.newURI(url, null, null).path.split("?")[0];
let startTime = Cu.now();
let start = Services.telemetry.getKeyedHistogramById('ABOUT_ACCOUNTS_CONTENT_SERVER_LOAD_STARTED_COUNT');
start.add(key);
recordResultTelemetry = function(success) {
let rate = Services.telemetry.getKeyedHistogramById('ABOUT_ACCOUNTS_CONTENT_SERVER_LOADED_RATE');
rate.add(key, success);
// We would prefer to use TelemetryStopwatch, but it doesn't yet support
// keyed histograms (see Bug 1205898). So we measure and store ourselves.
let delta = Cu.now() - startTime; // Floating point milliseconds, microsecond precision.
let time = success ?
Services.telemetry.getKeyedHistogramById('ABOUT_ACCOUNTS_CONTENT_SERVER_LOADED_TIME_MS') :
Services.telemetry.getKeyedHistogramById('ABOUT_ACCOUNTS_CONTENT_SERVER_FAILURE_TIME_MS');
time.add(key, Math.round(delta));
};
}
loadedDeferred = PromiseUtils.defer();
loadedDeferred.promise.then(() => {
log.d('Got LOADED message!');
document.getElementById("remote").style.opacity = 0;
show("remote");
document.getElementById("remote").style.opacity = 1;
if (!isCustomized) {
recordResultTelemetry(true);
}
})
.catch((e) => {
log.w('Did not get LOADED message: ' + e.toString());
if (!isCustomized) {
recordResultTelemetry(false);
}
});
}
@ -88,7 +131,8 @@ let wrapper = {
url: null,
init: function (url) {
deferTransitionToRemoteAfterLoaded();
this.url = url;
deferTransitionToRemoteAfterLoaded(this.url);
let iframe = document.getElementById("remote");
this.iframe = iframe;
@ -97,7 +141,6 @@ let wrapper = {
docShell.QueryInterface(Ci.nsIWebProgress);
docShell.addProgressListener(this.iframeListener, Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
this.url = url;
// Set the iframe's location with loadURI/LOAD_FLAGS_BYPASS_HISTORY to
// avoid having a new history entry being added.
let webNav = iframe.frameLoader.docShell.QueryInterface(Ci.nsIWebNavigation);
@ -105,7 +148,7 @@ let wrapper = {
},
retry: function () {
deferTransitionToRemoteAfterLoaded();
deferTransitionToRemoteAfterLoaded(this.url);
let webNav = this.iframe.frameLoader.docShell.QueryInterface(Ci.nsIWebNavigation);
webNav.loadURI(this.url, Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY, null, null, null);

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

@ -8868,6 +8868,38 @@
"kind": "count",
"description": "Counts the number of times that a sync has failed because of trying to sync before server backoff interval has passed."
},
"ABOUT_ACCOUNTS_CONTENT_SERVER_LOAD_STARTED_COUNT": {
"alert_emails": ["mobile-frontend@mozilla.com"],
"expires_in_version": "50",
"kind": "count",
"keyed": true,
"description": "The number of remote content loads started. Keyed on fxa-content-server endpoint, like '/signin' or '/settings'."
},
"ABOUT_ACCOUNTS_CONTENT_SERVER_LOADED_RATE": {
"alert_emails": ["mobile-frontend@mozilla.com"],
"expires_in_version": "50",
"kind": "boolean",
"keyed": true,
"description": "The number of remote content loads that fail (0) vs. receive the remote 'LOADED' message (1). Keyed on fxa-content-server endpoint path, like '/signin' or '/settings'."
},
"ABOUT_ACCOUNTS_CONTENT_SERVER_LOADED_TIME_MS": {
"alert_emails": ["mobile-frontend@mozilla.com"],
"expires_in_version": "50",
"keyed": true,
"kind": "exponential",
"high": "60000",
"n_buckets": 50,
"description": "The length of time (in milliseconds) between starting remote content load and receiving the remote 'LOADED' message. Keyed on fxa-content-server endpoint path, like '/signin' or '/settings'."
},
"ABOUT_ACCOUNTS_CONTENT_SERVER_FAILURE_TIME_MS": {
"alert_emails": ["mobile-frontend@mozilla.com"],
"expires_in_version": "50",
"keyed": true,
"kind": "exponential",
"high": "60000",
"n_buckets": 50,
"description": "The length of time (in milliseconds) between starting remote content load and failing with a connection error. Keyed on fxa-content-server endpoint path, like '/signin' or '/settings'."
},
"SLOW_SCRIPT_NOTICE_COUNT": {
"alert_emails": ["perf-telemetry-alerts@mozilla.com"],
"expires_in_version": "never",