Bug 1120409 - nsITelemetry.histogramSnapshots will no longer return keyed histograms. r=gfritzsche
authorGregory Moore <olucafont6@yahoo.com>
Wed, 22 Feb 2017 14:53:56 -0800
changeset 396516 5733e0b0e0969bdcdcd53ae25641bafeeae095bf
parent 396483 1b9293be51637f841275541d8991314ca56561a5
child 396517 009fb636215bd2f8b704f60bbdab68b30fe6f61f
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1120409
milestone55.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 1120409 - nsITelemetry.histogramSnapshots will no longer return keyed histograms. r=gfritzsche
toolkit/components/telemetry/TelemetryHistogram.cpp
toolkit/components/telemetry/tests/unit/test_TelemetryHistograms.js
--- a/toolkit/components/telemetry/TelemetryHistogram.cpp
+++ b/toolkit/components/telemetry/TelemetryHistogram.cpp
@@ -2274,16 +2274,22 @@ TelemetryHistogram::CreateHistogramSnaps
   // OK, now we can actually reflect things.
   JS::Rooted<JSObject*> hobj(cx);
   for (auto h : hs) {
     if (!internal_ShouldReflectHistogram(h) || internal_IsEmpty(h) ||
         internal_IsExpired(h)) {
       continue;
     }
 
+    mozilla::Telemetry::HistogramID id;
+    nsresult rv = internal_GetHistogramEnumId(h->histogram_name().c_str(), &id);
+    if (NS_WARN_IF(NS_FAILED(rv)) || gHistograms[id].keyed) {
+      continue;
+    }
+
     Histogram* original = h;
 #if !defined(MOZ_WIDGET_ANDROID)
     if (subsession) {
       h = internal_GetSubsessionHistogram(*h);
       if (!h) {
         continue;
       }
     }
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryHistograms.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryHistograms.js
@@ -752,16 +752,24 @@ add_task(function* test_keyed_histogram_
 
   // Restore to disabled
   Telemetry.setHistogramRecordingEnabled("TELEMETRY_TEST_KEYED_COUNT_INIT_NO_RECORD", false);
   h.add(TEST_KEY, 1);
   Assert.equal(h.snapshot(TEST_KEY).sum, 1,
     "Keyed histogram add should not record when recording is disabled");
 });
 
+add_task(function* test_histogramSnapshots() {
+  let keyed = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_COUNT");
+  keyed.add("a", 1);
+
+  // Check that keyed histograms are not returned
+  Assert.ok(!("TELEMETRY_TEST_KEYED_COUNT#a" in Telemetry.histogramSnapshots));
+});
+
 add_task(function* test_datasets() {
   // Check that datasets work as expected.
 
   const RELEASE_CHANNEL_OPTOUT = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT;
   const RELEASE_CHANNEL_OPTIN  = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN;
 
   // Check that registeredHistogram works properly
   let registered = Telemetry.registeredHistograms(RELEASE_CHANNEL_OPTIN, []);