Bug 1376942 - Added activeTicks as a scalar. r=dexter,gfritzsche;data-r=francois
authorVanessa Gutierrez <vgutierrez>
Thu, 20 Jul 2017 10:09:00 +0200
changeset 418902 6e1d1a0c2cca3f30e76d7bc30f9bbc4b1f38c5a3
parent 418901 ba3c77118fd3593e21e0d822e4b3a9b87c901869
child 418903 479136e0a11e5b3f790ae3972960ef476e8d68bb
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdexter, gfritzsche
bugs1376942
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1376942 - Added activeTicks as a scalar. r=dexter,gfritzsche;data-r=francois
toolkit/components/telemetry/Scalars.yaml
toolkit/components/telemetry/TelemetrySession.jsm
toolkit/components/telemetry/tests/unit/test_TelemetrySession.js
toolkit/components/telemetry/tests/unit/test_TelemetrySession_activeTicks.js
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -150,16 +150,32 @@ browser.engagement:
     expires: '62'
     kind: uint
     notification_emails:
       - chutten@mozilla.com
     release_channel_collection: opt-out
     record_in_processes:
       - 'main'
 
+  active_ticks:
+    bug_numbers:
+      - 1376942
+    description: >
+      The count of the number of five-second intervals ('ticks') the user
+      was considered 'active' in a subsession. Session activity involves keyboard or mouse
+      interaction with the application. It does not take into account whether or not the window
+      has focus or is in the foreground, only if it is receiving these interaction events.
+    expires: never
+    kind: uint
+    notification_emails:
+      - bcolloran@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'main'
+
 # The following section contains the browser engagement scalars.
 browser.engagement.navigation:
   urlbar:
     bug_numbers:
       - 1271313
     description: >
       The count URI loads triggered in a subsession from the urlbar (awesomebar),
       broken down by the originating action.
--- a/toolkit/components/telemetry/TelemetrySession.jsm
+++ b/toolkit/components/telemetry/TelemetrySession.jsm
@@ -1963,16 +1963,17 @@ var Impl = {
   _onActiveTick(aUserActive) {
     const needsUpdate = aUserActive && this._isUserActive;
     this._isUserActive = aUserActive;
 
     // Don't count the first active tick after we get out of
     // inactivity, because it is just the start of this active tick.
     if (needsUpdate) {
       this._sessionActiveTicks++;
+      Telemetry.scalarAdd("browser.engagement.active_ticks", 1);
     }
   },
 
   /**
    * This observer drives telemetry.
    */
   observe(aSubject, aTopic, aData) {
     // Prevent the cycle collector begin topic from cluttering the log.
--- a/toolkit/components/telemetry/tests/unit/test_TelemetrySession.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetrySession.js
@@ -945,39 +945,46 @@ add_task(async function test_checkSubses
 
   await TelemetryController.testReset();
 
   // Both classic and subsession payload data should be the same on the first subsession.
   incrementActiveTicks();
   let classic = TelemetrySession.getPayload();
   let subsession = TelemetrySession.getPayload("environment-change");
   Assert.equal(classic.simpleMeasurements.activeTicks, expectedActiveTicks,
-               "Classic pings must count active ticks since the beginning of the session.");
+    "Classic pings must count active ticks (in simpleMeasurements) since the beginning of the session.");
   Assert.equal(subsession.simpleMeasurements.activeTicks, expectedActiveTicks,
-               "Subsessions must count active ticks as classic pings on the first subsession.");
+    "Subsessions must count active ticks (in simpleMeasurements) as classic pings on the first subsession.");
+  Assert.equal(subsession.processes.parent.scalars["browser.engagement.active_ticks"], expectedActiveTicks,
+    "Subsessions must count active ticks (in scalars) as classic pings on the first subsession.");
 
   // Start a new subsession and check that the active ticks are correctly reported.
   incrementActiveTicks();
   activeTicksAtSubsessionStart = getActiveTicks();
   classic = TelemetrySession.getPayload();
   subsession = TelemetrySession.getPayload("environment-change", true);
   Assert.equal(classic.simpleMeasurements.activeTicks, expectedActiveTicks,
-               "Classic pings must count active ticks since the beginning of the session.");
+    "Classic pings must count active ticks (in simpleMeasurements) since the beginning of the session.");
   Assert.equal(subsession.simpleMeasurements.activeTicks, expectedActiveTicks,
-               "Pings must not loose the tick count when starting a new subsession.");
+    "Pings must not lose the tick count when starting a new subsession.");
+  Assert.equal(subsession.processes.parent.scalars["browser.engagement.active_ticks"], expectedActiveTicks,
+    "Active ticks (in scalars) must not lose count for a previous subsession when starting a new subsession.");
 
   // Get a new subsession payload without clearing the subsession.
   incrementActiveTicks();
   classic = TelemetrySession.getPayload();
   subsession = TelemetrySession.getPayload("environment-change");
   Assert.equal(classic.simpleMeasurements.activeTicks, expectedActiveTicks,
-               "Classic pings must count active ticks since the beginning of the session.");
+    "Classic pings must count active ticks (in simpleMeasurements) since the beginning of the session.");
   Assert.equal(subsession.simpleMeasurements.activeTicks,
-               expectedActiveTicks - activeTicksAtSubsessionStart,
-               "Subsessions must count active ticks since the last new subsession.");
+    expectedActiveTicks - activeTicksAtSubsessionStart,
+    "Subsessions must count active ticks (in simpleMeasurements) since the last new subsession.");
+  Assert.equal(subsession.processes.parent.scalars["browser.engagement.active_ticks"],
+    expectedActiveTicks - activeTicksAtSubsessionStart,
+    "Subsessions must count active ticks (in scalars) since the last new subsession.");
 
   await TelemetryController.testShutdown();
 });
 
 add_task(async function test_dailyCollection() {
   if (gIsAndroid) {
     // We don't do daily collections yet on Android.
     return;
--- a/toolkit/components/telemetry/tests/unit/test_TelemetrySession_activeTicks.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetrySession_activeTicks.js
@@ -16,20 +16,26 @@ add_task(async function test_setup() {
 
   Services.prefs.setBoolPref(TelemetryUtils.Preferences.TelemetryEnabled, true);
 });
 
 add_task(async function test_record_activeTicks() {
   await TelemetryController.testSetup();
 
   let checkActiveTicks = (expected) => {
-    let payload = TelemetrySession.getPayload();
+    // Scalars are only present in subsession payloads.
+    let payload = TelemetrySession.getPayload("main");
     Assert.equal(payload.simpleMeasurements.activeTicks, expected,
-                 "TelemetrySession must record the expected number of active ticks.");
-  };
+                 "TelemetrySession must record the expected number of active ticks (in simpleMeasurements).");
+    // Subsessions are not yet supported on Android.
+    if (!gIsAndroid) {
+      Assert.equal(payload.processes.parent.scalars["browser.engagement.active_ticks"], expected,
+                   "TelemetrySession must record the expected number of active ticks (in scalars).");
+    }
+  }
 
   for (let i = 0; i < 3; i++) {
     Services.obs.notifyObservers(null, "user-interaction-active");
   }
   checkActiveTicks(3);
 
   // Now send inactive. This must not increment the active ticks.
   Services.obs.notifyObservers(null, "user-interaction-inactive");