tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit baa8bf06bae0790c4f7d5d7fa77e550249118078
parent ff9f9beb791e37ffb80389745e3eeed48a6fc99d
Author: Jan-Erik Rediger <jrediger@mozilla.com>
Date:   Fri, 24 Oct 2025 12:39:28 +0000

Bug 1991891 - Make `GIFFT_NON_PING_LIFETIME` lint an actual lint known to glean_parser r=TravisLong

Differential Revision: https://phabricator.services.mozilla.com/D269373

Diffstat:
Mtoolkit/components/glean/build_scripts/glean_parser_ext/run_glean_parser.py | 39+++++++++++++++++++++++++--------------
1 file changed, 25 insertions(+), 14 deletions(-)

diff --git a/toolkit/components/glean/build_scripts/glean_parser_ext/run_glean_parser.py b/toolkit/components/glean/build_scripts/glean_parser_ext/run_glean_parser.py @@ -14,7 +14,7 @@ import rust import typescript from buildconfig import topsrcdir from glean_parser import lint, metrics, parser, translate, util -from glean_parser.lint import CheckType, GlinterNit +from glean_parser.lint import METRIC_CHECKS, CheckType, GlinterNit from glean_parser.pings import Ping from metrics_header_names import convert_yaml_path_to_header_name from mozbuild.util import FileAvoidWrite, memoize @@ -23,6 +23,30 @@ from util import generate_metric_ids import js +def lint_gifft_non_ping_lifetime(metric, parser_config): + """ + We only support mirrors for lifetime: ping + If you understand and are okay with how Legacy Telemetry has no + mechanism to which to mirror non-ping lifetimes, + you may use `no_lint: [GIFFT_NON_PING_LIFETIME]` + """ + + if not hasattr(metric, "telemetry_mirror") or metric.telemetry_mirror is None: + return + + if metric.lifetime != metrics.Lifetime.ping: + yield ( + f"Glean lifetime semantics are not mirrored. The lifetime of {metric.lifetime} is not supported." + ) + + +# Add to the built-in lints +METRIC_CHECKS["GIFFT_NON_PING_LIFETIME"] = ( + lint_gifft_non_ping_lifetime, + CheckType.warning, +) + + @memoize def get_deps(): # Any imported python module is added as a dep automatically, @@ -360,19 +384,6 @@ def output_gifft_map(output_fd, probe_type, all_objs, cpp_fd, options): file=sys.stderr, ) sys.exit(1) - # We only support mirrors for lifetime: ping - # If you understand and are okay with how Legacy Telemetry has no - # mechanism to which to mirror non-ping lifetimes, - # you may use `no_lint: [GIFFT_NON_PING_LIFETIME]` - elif ( - metric.lifetime != metrics.Lifetime.ping - and "GIFFT_NON_PING_LIFETIME" not in metric.no_lint - ): - print( - f"Glean lifetime semantics are not mirrored. {category_name}.{metric.name}'s lifetime of {metric.lifetime} is not supported.", - file=sys.stderr, - ) - sys.exit(1) env = jinja2.Environment( loader=jinja2.PackageLoader("run_glean_parser", "templates"),