Skip to content

Commit

Permalink
Bug 958561 - Measure Sync with Firefox Health Report; r=rnewman
Browse files Browse the repository at this point in the history
Metrics for Sync have been added to Firefox Health Report. If Sync is
not configured, we'll report that fact and the supported and preferred
Sync protocols (1.1 or 1.5).

If Sync is configured, we report the daily counts of sync attempts and
how many are successful vs errored. We also report daily counts of the
device types attached to the account.

--HG--
extra : rebase_source : 77170b323706a85cbe1542ac993ebdc1dba3b505
extra : amend_source : 7802e80b4fc94937fbe3f67505b447bfb048732d
  • Loading branch information
indygreg committed Feb 5, 2014
1 parent 5aa0cf2 commit 4e49d56
Show file tree
Hide file tree
Showing 14 changed files with 547 additions and 10 deletions.
22 changes: 21 additions & 1 deletion build/docs/mozinfo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ crashreporter
Always defined.

datareporting
Whether data reporting (MOZ_DATA_REPORTING) is enabled for this build.
Whether data reporting (MOZ_DATA_REPORTING) is enabled for this build.

Values are ``true`` and ``false``.

Expand All @@ -86,6 +86,13 @@ debug

Always defined.

healthreport
Whether the Health Report feature is enabled.

Values are ``true`` and ``false``.

Always defined.

mozconfig
The path of the :ref:`mozconfig file <mozconfig>` used to produce this build.

Expand Down Expand Up @@ -133,3 +140,16 @@ topsrcdir

Always defined.

wave
Whether Wave audio support is enabled.

Values are ``true`` and ``false``.

Always defined.

webm
Whether WebM support is enabled.

Values are ``true`` and ``false``.

Always defined.
1 change: 1 addition & 0 deletions python/mozbuild/mozbuild/mozinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def build_dict(config, env=os.environ):
d['debug'] = substs.get('MOZ_DEBUG') == '1'
d['crashreporter'] = bool(substs.get('MOZ_CRASHREPORTER'))
d['datareporting'] = bool(substs.get('MOZ_DATA_REPORTING'))
d['healthreport'] = substs.get('MOZ_SERVICES_HEALTHREPORT') == '1'
d['asan'] = substs.get('MOZ_ASAN') == '1'
d['tests_enabled'] = substs.get('ENABLE_TESTS') == "1"
d['bin_suffix'] = substs.get('BIN_SUFFIX', '')
Expand Down
68 changes: 68 additions & 0 deletions services/healthreport/docs/dataformat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,74 @@ Example
"google.urlbar": 7
},
org.mozilla.sync.sync
---------------------
This daily measurement contains information about the Sync service.
Values should be recorded for every day FHR measurements occurred.
Version 1
^^^^^^^^^
This version debuted with Firefox 30 on desktop. It contains the following
properties:
enabled
Daily numeric indicating whether Sync is configured and enabled. 1 if so,
0 otherwise.
preferredProtocol
String version of the maximum Sync protocol version the client supports.
This will be ``1.1`` for for legacy Sync and ``1.5`` for clients that
speak the Firefox Accounts protocol.

actualProtocol
The actual Sync protocol version the client is configured to use.

This will be ``1.1`` if the client is configured with the legacy Sync
service or if the client only supports ``1.1``.

It will be ``1.5`` if the client supports ``1.5`` and either a) the
client is not configured b) the client is using Firefox Accounts Sync.

syncStart
Count of sync operations performed.

syncSuccess
Count of sync operations that completed successfully.

syncError
Count of sync operations that did not complete successfully.

This is a measure of overall sync success. This does *not* reflect
recoverable errors (such as record conflict) that can occur during
sync. This is thus a rough proxy of whether the sync service is
operating without error.

org.mozilla.sync.devices
------------------------

This daily measurement contains information about the device type composition
for the configured Sync account.

Version 1
^^^^^^^^^

Version 1 was introduced with Firefox 30.

Field names are dynamic according to the client-reported device types from
Sync records. All fields are daily last seen integer values corresponding to
the number of devices of that type.

Common values include:

desktop
Corresponds to a Firefox desktop client.

mobile
Corresponds to a Fennec client.

org.mozilla.sysinfo.sysinfo
---------------------------

Expand Down
10 changes: 7 additions & 3 deletions services/metrics/providermanager.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,14 @@ this.ProviderManager.prototype = Object.freeze({
* @return Promise<null>
*/
registerProvider: function (provider) {
if (!(provider instanceof Provider)) {
throw new Error("Argument must be a Provider instance.");
// We should perform an instanceof check here. However, due to merged
// compartments, the Provider type may belong to one of two JSMs
// isinstance gets confused depending on which module Provider comes
// from. Some code references Provider from dataprovider.jsm; others from
// Metrics.jsm.
if (!provider.name) {
throw new Error("Provider is not valid: does not have a name.");
}

if (this._providers.has(provider.name)) {
return CommonUtils.laterTickResolvingPromise();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ add_task(function test_register_provider() {
try {
manager.registerProvider({});
} catch (ex) {
do_check_true(ex.message.startsWith("Argument must be a Provider"));
do_check_true(ex.message.startsWith("Provider is not valid"));
failed = true;
} finally {
do_check_true(failed);
Expand Down
1 change: 1 addition & 0 deletions services/sync/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ sync_modules := \
addonutils.js \
browserid_identity.js \
engines.js \
healthreport.jsm \
identity.js \
jpakeclient.js \
keys.js \
Expand Down
4 changes: 4 additions & 0 deletions services/sync/SyncComponents.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ contract @mozilla.org/network/protocol/about;1?what=sync-log {d28f8a0b-95da-48f4
# Register resource aliases
# (Note, for tests these are also set up in addResourceAlias)
resource services-sync resource://gre/modules/services-sync/

#ifdef MOZ_SERVICES_HEALTHREPORT
category healthreport-js-provider-default SyncProvider resource://services-sync/healthreport.jsm
#endif
20 changes: 20 additions & 0 deletions services/sync/Weave.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ WeaveService.prototype = {
return deferred.promise;
},

/**
* Whether Firefox Accounts is enabled.
*
* @return bool
*/
get fxAccountsEnabled() {
// work out what identity manager to use. This is stored in a preference;
// if the preference exists, we trust it.
Expand All @@ -112,6 +117,21 @@ WeaveService.prototype = {
return fxAccountsEnabled;
},

/**
* Whether Sync appears to be enabled.
*
* This returns true if all the Sync preferences for storing account
* and server configuration are populated.
*
* It does *not* perform a robust check to see if the client is working.
* For that, you'll want to check Weave.Status.checkSetup().
*/
get enabled() {
let prefs = Services.prefs.getBranch(SYNC_PREFS_BRANCH);
return prefs.prefHasUserValue("username") &&
prefs.prefHasUserValue("clusterURL");
},

observe: function (subject, topic, data) {
switch (topic) {
case "app-startup":
Expand Down
22 changes: 22 additions & 0 deletions services/sync/modules/engines/clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,28 @@ ClientEngine.prototype = {
return stats;
},

/**
* Obtain information about device types.
*
* Returns a Map of device types to integer counts.
*/
get deviceTypes() {
let counts = new Map();

counts.set(this.localType, 1);

for each (let record in this._store._remoteClients) {
let type = record.type;
if (!counts.has(type)) {
counts.set(type, 0);
}

counts.set(type, counts.get(type) + 1);
}

return counts;
},

get localID() {
// Generate a random GUID id we don't have one
let localID = Svc.Prefs.get("client.GUID", "");
Expand Down
Loading

0 comments on commit 4e49d56

Please sign in to comment.