Bug 1229083 - [Metrics] addonHistograms missing a level. r=janx
authorTamara Hills <thills@mozilla.com>
Thu, 17 Dec 2015 06:48:00 +0100
changeset 277101 371837ab6f35
parent 277100 9422b8d90fee
child 277102 1a11309e66f8
push id29817
push usercbook@mozilla.com
push date2015-12-22 10:35 +0000
treeherdermozilla-central@1ff07674040e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanx
bugs1229083
milestone46.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 1229083 - [Metrics] addonHistograms missing a level. r=janx
b2g/chrome/content/devtools/hud.js
--- a/b2g/chrome/content/devtools/hud.js
+++ b/b2g/chrome/content/devtools/hud.js
@@ -3,16 +3,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 'use strict';
 
 // settings.js loads this file when the HUD setting is enabled.
 
 const DEVELOPER_HUD_LOG_PREFIX = 'DeveloperHUD';
 const CUSTOM_HISTOGRAM_PREFIX = 'DEVTOOLS_HUD_CUSTOM_';
+const APPNAME_IDX = 3;
+const HISTNAME_IDX = 4;
 
 XPCOMUtils.defineLazyGetter(this, 'devtools', function() {
   const {devtools} = Cu.import('resource://devtools/shared/Loader.jsm', {});
   return devtools;
 });
 
 XPCOMUtils.defineLazyGetter(this, 'DebuggerClient', function() {
   return devtools.require('devtools/shared/client/main').DebuggerClient;
@@ -317,24 +319,26 @@ Target.prototype = {
   _send(data) {
     let frame = this.frame;
 
     shell.sendEvent(frame, 'developer-hud-update', Cu.cloneInto(data, frame));
     this._logHistogram(data.metric);
   },
 
   _getAddonHistogram(item) {
-    let APPNAME_IDX = 3;
-    let HISTNAME_IDX = 4;
+    let appName = this._getAddonHistogramName(item, APPNAME_IDX);
+    let histName = this._getAddonHistogramName(item, HISTNAME_IDX);
 
+    return Services.telemetry.getAddonHistogram(appName, CUSTOM_HISTOGRAM_PREFIX
+      + histName);
+  },
+
+  _getAddonHistogramName(item, index) {
     let array = item.split('_');
-    let appName = array[APPNAME_IDX].toUpperCase();
-    let histName = array[HISTNAME_IDX].toUpperCase();
-    return Services.telemetry.getAddonHistogram(appName,
-      CUSTOM_HISTOGRAM_PREFIX + histName);
+    return array[index].toUpperCase();
   },
 
   _clearTelemetryData() {
     developerHUD._histograms.forEach(function(item) {
       Services.telemetry.getKeyedHistogramById(item).clear();
     });
 
     developerHUD._customHistograms.forEach(item => {
@@ -352,21 +356,31 @@ Target.prototype = {
       keyedHistograms: {},
       addonHistograms: {}
     };
     // Package the hud histograms.
     developerHUD._histograms.forEach(function(item) {
       payload.keyedHistograms[item] =
         Services.telemetry.getKeyedHistogramById(item).snapshot();
     });
+
     // Package the registered hud custom histograms
     developerHUD._customHistograms.forEach(item => {
-      payload.addonHistograms[item] = this._getAddonHistogram(item).snapshot();
+      let appName = this._getAddonHistogramName(item, APPNAME_IDX);
+      let histName = CUSTOM_HISTOGRAM_PREFIX +
+        this._getAddonHistogramName(item, HISTNAME_IDX);
+      let addonHist = Services.telemetry.getAddonHistogram(appName, histName).snapshot();
+      if (!(appName in payload.addonHistograms)) {
+        payload.addonHistograms[appName] = {};
+      }
+      // Do not include histograms with sum of 0.
+      if (addonHist.sum > 0) {
+        payload.addonHistograms[appName][histName] = addonHist;
+      }
     });
-
     shell.sendEvent(frame, 'advanced-telemetry-update', Cu.cloneInto(payload, frame));
   },
 
   _logHistogram(metric) {
     if (!developerHUD._telemetry || metric.skipTelemetry) {
       return;
     }