From 4e2b16193703a6195f9d59e420a8a9fa3e7070ef Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Thu, 1 Dec 2022 16:37:22 +0100 Subject: [PATCH] Correctly serialize `Rate`s as documented into `CommonMetricData` --- glean_parser/rust.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/glean_parser/rust.py b/glean_parser/rust.py index 177b62c70..70345d055 100644 --- a/glean_parser/rust.py +++ b/glean_parser/rust.py @@ -63,6 +63,17 @@ def iterencode(self, value): yield "None" elif isinstance(value, str): yield f'"{value}".into()' + elif isinstance(value, metrics.Rate): + yield "CommonMetricData(" + first = True + for arg_name in util.common_metric_args: + if hasattr(value, arg_name): + if not first: + yield ", " + yield f"{util.camelize(arg_name)} = " + yield from self.iterencode(getattr(value, arg_name)) + first = False + yield ")" else: yield from super().iterencode(value)