I recently landed changes (
https://bugzilla.mozilla.org/show_bug.cgi?id=1879329) to how Glean generates C++ headers from metrics defined in metrics.yaml files.
It used to generate a single GleanMetrics.h file that every C++ file using Glean had to include, which meant that any change to any Glean metric caused a change of that big header, which triggered broad rebuilds of platform code.
It will now generate a header file per metrics.yaml file allowing C++ code to include only relevant subsets of metric definitions.
The names of header files are based on the path to the metrics.yaml file (inspired from what is done for StaticPrefs headers). The folder separators, - and _ characters are replaced with an uppercase letter in the path.
For example, to include metric definitions from toolkit/profile/metrics.yaml, the C++ code will now #include "mozilla/glean/ToolkitProfileMetrics.h"
Some exceptions were made to the general rule to make file names shorter and nicer:
- The ‘/base/‘ folders are ignored. (ie. the header is named BrowserContentMetrics.h rather than BrowserBaseContentMetrics.h)
- {browser,toolkit}/components/componentname/metrics.yaml is treated as if it was just componentname/metrics.yaml (ie. include PlacesMetrics.h rather than BrowserComponentsPlacesMetrics.yaml)
To see the full list of exceptions or if you need to add more, you can find the code generating header names in
https://searchfox.org/mozilla-central/source/toolkit/components/glean/build_scripts/glean_parser_ext/metrics_header_names.pyAll the existing includes of GleanMetrics.h have been rewritten.