Bug 1477433 - Enable use-counters on release channel (r=chutten)
authorDietrich Ayala <dietrich@mozilla.com>
Thu, 15 Nov 2018 08:39:13 +0000
changeset 446549 eff95fc19f19f108a7554f74e456f9fd7664541a
parent 446548 76aa81358d762cbc618c1913061b57eccc145b1d
child 446550 d76f007bee63b3730068f1a5549bd4d6513593c7
push id35043
push userebalazs@mozilla.com
push dateThu, 15 Nov 2018 16:12:36 +0000
treeherdermozilla-central@59026ada59bd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1477433
milestone65.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 1477433 - Enable use-counters on release channel (r=chutten) Enable use-counters on release channel Differential Revision: https://phabricator.services.mozilla.com/D11470
toolkit/components/telemetry/build_scripts/mozparsers/parse_histograms.py
toolkit/components/telemetry/tests/python/python.ini
toolkit/components/telemetry/tests/python/test_usecounters.py
--- a/toolkit/components/telemetry/build_scripts/mozparsers/parse_histograms.py
+++ b/toolkit/components/telemetry/build_scripts/mozparsers/parse_histograms.py
@@ -128,16 +128,17 @@ definition is a dict-like object that mu
  - 'description': A textual description of the histogram.
  - 'strict_type_checks': A boolean indicating whether to use the new, stricter type checks.
                          The server-side still has to deal with old, oddly typed submissions,
                          so we have to skip them there by default."""
         self._strict_type_checks = strict_type_checks
         self._is_use_counter = name.startswith("USE_COUNTER2_")
         if self._is_use_counter:
             definition.setdefault('record_in_processes', ['main', 'content'])
+            definition.setdefault('releaseChannelCollection', 'opt-out')
         self.verify_attributes(name, definition)
         self._name = name
         self._description = definition['description']
         self._kind = definition['kind']
         self._keys = definition.get('keys', [])
         self._keyed = definition.get('keyed', False)
         self._expiration = definition.get('expires_in_version')
         self._labels = definition.get('labels', [])
--- a/toolkit/components/telemetry/tests/python/python.ini
+++ b/toolkit/components/telemetry/tests/python/python.ini
@@ -1,8 +1,9 @@
 [DEFAULT]
 skip-if = python == 3
 
 [test_gen_event_data_json.py]
 [test_gen_scalar_data_json.py]
 [test_histogramtools_non_strict.py]
 [test_histogramtools_strict.py]
 [test_parse_scalars.py]
+[test_usecounters.py]
new file mode 100644
--- /dev/null
+++ b/toolkit/components/telemetry/tests/python/test_usecounters.py
@@ -0,0 +1,61 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import mozunit
+import sys
+import unittest
+from os import path
+from test_histogramtools_non_strict import load_histogram
+
+TELEMETRY_ROOT_PATH = path.abspath(path.join(path.dirname(__file__), path.pardir, path.pardir))
+sys.path.append(TELEMETRY_ROOT_PATH)
+# The parsers live in a subdirectory of "build_scripts", account for that.
+# NOTE: if the parsers are moved, this logic will need to be updated.
+sys.path.append(path.join(TELEMETRY_ROOT_PATH, "build_scripts"))
+from mozparsers.shared_telemetry_utils import ParserError
+from mozparsers import parse_histograms
+
+
+class TestParser(unittest.TestCase):
+    def test_usecounter_collection_enabled(self):
+        SAMPLE_HISTOGRAM = {
+            "USE_COUNTER2_TEST_HISTOGRAM": {
+                "expires_in_version": "never",
+                "kind": "boolean",
+                "description": "Whether a foo used bar"
+            }
+        }
+        histograms = load_histogram(SAMPLE_HISTOGRAM)
+        parse_histograms.load_whitelist()
+
+        hist = parse_histograms.Histogram('USE_COUNTER2_TEST_HISTOGRAM',
+                                          histograms['USE_COUNTER2_TEST_HISTOGRAM'],
+                                          strict_type_checks=True)
+
+        ParserError.exit_func()
+        self.assertEquals(hist.dataset(), "nsITelemetry::DATASET_RELEASE_CHANNEL_OPTOUT")
+
+    def test_usecounter_histogram(self):
+        SAMPLE_HISTOGRAM = {
+            "USE_COUNTER2_TEST_HISTOGRAM": {
+                "expires_in_version": "never",
+                "kind": "boolean",
+                "description": "Whether a foo used bar"
+            }
+        }
+        histograms = load_histogram(SAMPLE_HISTOGRAM)
+        parse_histograms.load_whitelist()
+
+        hist = parse_histograms.Histogram('USE_COUNTER2_TEST_HISTOGRAM',
+                                          histograms['USE_COUNTER2_TEST_HISTOGRAM'],
+                                          strict_type_checks=True)
+
+        ParserError.exit_func()
+        self.assertEquals(hist.expiration(), "never")
+        self.assertEquals(hist.kind(), "boolean")
+        self.assertEquals(hist.description(), "Whether a foo used bar")
+
+
+if __name__ == '__main__':
+    mozunit.main()