diff --git a/toolkit/components/telemetry/gen-histogram-bucket-ranges.py b/toolkit/components/telemetry/gen-histogram-bucket-ranges.py index a8021fe332f8..7a2f1b697867 100644 --- a/toolkit/components/telemetry/gen-histogram-bucket-ranges.py +++ b/toolkit/components/telemetry/gen-histogram-bucket-ranges.py @@ -7,7 +7,7 @@ # buckets specified by each histogram. import sys -import histogram_tools +import parse_histograms import json from collections import OrderedDict @@ -18,7 +18,7 @@ def main(argv): all_histograms = OrderedDict() - for histogram in histogram_tools.from_files(filenames): + for histogram in parse_histograms.from_files(filenames): name = histogram.name() parameters = OrderedDict() table = { @@ -30,8 +30,8 @@ def main(argv): 'count': '4', } # Use __setitem__ because Python lambdas are so limited. - histogram_tools.table_dispatch(histogram.kind(), table, - lambda k: parameters.__setitem__('kind', k)) + parse_histograms.table_dispatch(histogram.kind(), table, + lambda k: parameters.__setitem__('kind', k)) if histogram.low() == 0: parameters['min'] = 1 else: @@ -42,7 +42,7 @@ def main(argv): parameters['buckets'] = buckets parameters['max'] = buckets[-1] parameters['bucket_count'] = len(buckets) - except histogram_tools.DefinitionException: + except parse_histograms.DefinitionException: continue all_histograms.update({name: parameters}) diff --git a/toolkit/components/telemetry/gen_histogram_data.py b/toolkit/components/telemetry/gen_histogram_data.py index fac3fa4326f0..ced272be97e4 100644 --- a/toolkit/components/telemetry/gen_histogram_data.py +++ b/toolkit/components/telemetry/gen_histogram_data.py @@ -9,7 +9,7 @@ from __future__ import print_function from shared_telemetry_utils import StringTable, static_assert, ParserError import sys -import histogram_tools +import parse_histograms banner = """/* This file is auto-generated, see gen_histogram_data.py. */ """ @@ -193,7 +193,7 @@ def write_histogram_ranges(output, histograms): def main(output, *filenames): try: - histograms = list(histogram_tools.from_files(filenames)) + histograms = list(parse_histograms.from_files(filenames)) except ParserError as ex: print("\nError processing histograms:\n" + str(ex) + "\n") sys.exit(1) diff --git a/toolkit/components/telemetry/gen_histogram_enum.py b/toolkit/components/telemetry/gen_histogram_enum.py index ced93d94df4c..9b92ab5a33f1 100644 --- a/toolkit/components/telemetry/gen_histogram_enum.py +++ b/toolkit/components/telemetry/gen_histogram_enum.py @@ -15,7 +15,7 @@ from __future__ import print_function from shared_telemetry_utils import ParserError -import histogram_tools +import parse_histograms import itertools import sys @@ -46,7 +46,7 @@ def main(output, *filenames): # Load the histograms. try: - all_histograms = list(histogram_tools.from_files(filenames)) + all_histograms = list(parse_histograms.from_files(filenames)) except ParserError as ex: print("\nError processing histograms:\n" + str(ex) + "\n") sys.exit(1) @@ -55,7 +55,7 @@ def main(output, *filenames): lambda h: h.name().startswith("USE_COUNTER2_")) # Print the histogram enums. - # Note that histogram_tools.py guarantees that all of the USE_COUNTER2_* + # Note that parse_histograms.py guarantees that all of the USE_COUNTER2_* # histograms are defined in a contiguous block. We therefore assume # that there's at most one group for which use_counter_group is true. print("enum HistogramID : uint32_t {", file=output) diff --git a/toolkit/components/telemetry/histogram_tools.py b/toolkit/components/telemetry/parse_histograms.py similarity index 99% rename from toolkit/components/telemetry/histogram_tools.py rename to toolkit/components/telemetry/parse_histograms.py index e18d4051c3e4..02b4c13650e1 100755 --- a/toolkit/components/telemetry/histogram_tools.py +++ b/toolkit/components/telemetry/parse_histograms.py @@ -40,7 +40,7 @@ BASE_DOC_URL = ("https://firefox-source-docs.mozilla.org/toolkit/components/" HISTOGRAMS_DOC_URL = (BASE_DOC_URL + "collection/histograms.html") SCALARS_DOC_URL = (BASE_DOC_URL + "collection/scalars.html") -# histogram_tools.py is used by scripts from a mozilla-central build tree +# parse_histograms.py is used by scripts from a mozilla-central build tree # and also by outside consumers, such as the telemetry server. We need # to ensure that importing things works in both contexts. Therefore, # unconditionally importing things that are local to the build tree, such diff --git a/toolkit/components/telemetry/tests/python/test_histogramtools_non_strict.py b/toolkit/components/telemetry/tests/python/test_histogramtools_non_strict.py index 067a48b45a33..4c527146ea9c 100644 --- a/toolkit/components/telemetry/tests/python/test_histogramtools_non_strict.py +++ b/toolkit/components/telemetry/tests/python/test_histogramtools_non_strict.py @@ -10,7 +10,7 @@ from os import path TELEMETRY_ROOT_PATH = path.abspath(path.join(path.dirname(__file__), path.pardir, path.pardir)) sys.path.append(TELEMETRY_ROOT_PATH) -import histogram_tools # noqa: E402 +import parse_histograms # noqa: E402 def load_histogram(histograms): @@ -21,7 +21,7 @@ def load_histogram(histograms): :returns: Parsed Histogram dictionary mapping histogram names to histogram parameters """ def hook(ps): - return histogram_tools.load_histograms_into_dict(ps, strict_type_checks=False) + return parse_histograms.load_histograms_into_dict(ps, strict_type_checks=False) return json.loads(json.dumps(histograms), object_pairs_hook=hook) @@ -37,9 +37,9 @@ class TestParser(unittest.TestCase): }} histograms = load_histogram(SAMPLE_HISTOGRAM) - hist = histogram_tools.Histogram('A11Y_INSTANTIATED_FLAG', - histograms['A11Y_INSTANTIATED_FLAG'], - strict_type_checks=False) + hist = parse_histograms.Histogram('A11Y_INSTANTIATED_FLAG', + histograms['A11Y_INSTANTIATED_FLAG'], + strict_type_checks=False) self.assertEqual(hist.expiration(), 'never') self.assertEqual(hist.kind(), 'flag') self.assertEqual(hist.record_in_processes(), ["main", "content"]) @@ -54,18 +54,18 @@ class TestParser(unittest.TestCase): }} histograms = load_histogram(SAMPLE_HISTOGRAM) - hist = histogram_tools.Histogram('TEST_NON_NUMERIC_HISTOGRAM', - histograms['TEST_NON_NUMERIC_HISTOGRAM'], - strict_type_checks=False) + hist = parse_histograms.Histogram('TEST_NON_NUMERIC_HISTOGRAM', + histograms['TEST_NON_NUMERIC_HISTOGRAM'], + strict_type_checks=False) - # expected values come off histogram_tools.py + # expected values come off parse_histograms.py self.assertEqual(hist.n_buckets(), 101) self.assertEqual(hist.high(), 12) def test_current_histogram(self): HISTOGRAMS_PATH = path.join(TELEMETRY_ROOT_PATH, "Histograms.json") - all_histograms = list(histogram_tools.from_files([HISTOGRAMS_PATH], - strict_type_checks=False)) + all_histograms = list(parse_histograms.from_files([HISTOGRAMS_PATH], + strict_type_checks=False)) test_histogram = [i for i in all_histograms if i.name() == 'TELEMETRY_TEST_FLAG'][0] self.assertEqual(test_histogram.expiration(), 'never')