Bug 1065285 - Add telemetry for the last maintenance time. r=mak
authorManu Jain <manu.jain13@gmail.com>
Sat, 27 Sep 2014 03:47:00 -0400
changeset 207933 9687a6f92e7d054dfcbf5dfe3f1013867c3a4ae8
parent 207932 0ec9bd8e988017a9088b9d28cef09a6a10151ac8
child 207934 88f608a55a0a01add1fb4f231f13445451a51d1d
push id9067
push userryanvm@gmail.com
push dateTue, 30 Sep 2014 14:44:15 +0000
treeherderfx-team@9687a6f92e7d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1065285
milestone35.0a1
Bug 1065285 - Add telemetry for the last maintenance time. r=mak
toolkit/components/places/PlacesDBUtils.jsm
toolkit/components/places/tests/unit/test_telemetry.js
toolkit/components/telemetry/Histograms.json
--- a/toolkit/components/places/PlacesDBUtils.jsm
+++ b/toolkit/components/places/PlacesDBUtils.jsm
@@ -952,16 +952,28 @@ this.PlacesDBUtils = {
       { histogram: "PLACES_ANNOS_BOOKMARKS_SIZE_KB",
         query:     "SELECT SUM(LENGTH(content))/1024 FROM moz_items_annos" },
 
       { histogram: "PLACES_ANNOS_PAGES_COUNT",
         query:     "SELECT count(*) FROM moz_annos" },
 
       { histogram: "PLACES_ANNOS_PAGES_SIZE_KB",
         query:     "SELECT SUM(LENGTH(content))/1024 FROM moz_annos" },
+
+      { histogram: "PLACES_MAINTENANCE_DAYSFROMLAST",
+        callback: function () {
+          try {
+            let lastMaintenance = Services.prefs.getIntPref("places.database.lastMaintenance");
+            let nowSeconds = parseInt(Date.now() / 1000);
+            return parseInt((nowSeconds - lastMaintenance) / 86400);
+          } catch (ex) {
+            return 60;
+          }
+        }
+      },
     ];
 
     let params = {
       tags_folder: PlacesUtils.tagsFolderId,
       type_folder: PlacesUtils.bookmarks.TYPE_FOLDER,
       type_bookmark: PlacesUtils.bookmarks.TYPE_BOOKMARK,
       places_root: PlacesUtils.placesRootId
     };
--- a/toolkit/components/places/tests/unit/test_telemetry.js
+++ b/toolkit/components/places/tests/unit/test_telemetry.js
@@ -22,16 +22,17 @@ let histograms = {
   //PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS:  function (val) do_check_true(val > 1),
   PLACES_IDLE_FRECENCY_DECAY_TIME_MS: function (val) do_check_true(val > 0),
   PLACES_IDLE_MAINTENANCE_TIME_MS: function (val) do_check_true(val > 0),
   PLACES_ANNOS_BOOKMARKS_COUNT: function (val) do_check_eq(val, 1),
   PLACES_ANNOS_BOOKMARKS_SIZE_KB: function (val) do_check_eq(val, 1),
   PLACES_ANNOS_PAGES_COUNT: function (val) do_check_eq(val, 1),
   PLACES_ANNOS_PAGES_SIZE_KB: function (val) do_check_eq(val, 1),
   PLACES_FRECENCY_CALC_TIME_MS: function (val) do_check_true(val >= 0),
+  PLACES_MAINTENANCE_DAYSFROMLAST: function (val) do_check_true(val >= 0),
 }
 
 function run_test()
 {
   run_next_test();
 }
 
 add_task(function test_execute()
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -3403,16 +3403,24 @@
     "alert_emails": ["places-telemetry-alerts@mozilla.com"],
     "expires_in_version": "40",
     "kind": "exponential",
     "high": "100",
     "n_buckets": 10,
     "extended_statistics_ok": true,
     "description": "PLACES: Time to calculate frecency of a page (ms)"
   },
+  "PLACES_MAINTENANCE_DAYSFROMLAST": {
+    "expires_in_version" : "never",
+    "kind": "exponential",
+    "low": 7,
+    "high": 60,
+    "n_buckets" : 10,
+    "description": "PLACES: Days from last maintenance"
+  },
   "UPDATER_BACKGROUND_CHECK_CODE_EXTERNAL": {
     "expires_in_version": "default",
     "kind": "enumerated",
     "n_values": 50,
     "description": "Updater: externally initiated (typically by the application) background update check result code (see PING_BGUC_* constants defined in /toolkit/mozapps/update/nsUpdateService.js)"
   },
   "UPDATER_BACKGROUND_CHECK_CODE_NOTIFY": {
     "expires_in_version": "40",