Skip to content

Commit 4e2b161

Browse files
committed
Correctly serialize Rates as documented into CommonMetricData
1 parent 0960293 commit 4e2b161

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

glean_parser/rust.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ def iterencode(self, value):
6363
yield "None"
6464
elif isinstance(value, str):
6565
yield f'"{value}".into()'
66+
elif isinstance(value, metrics.Rate):
67+
yield "CommonMetricData("
68+
first = True
69+
for arg_name in util.common_metric_args:
70+
if hasattr(value, arg_name):
71+
if not first:
72+
yield ", "
73+
yield f"{util.camelize(arg_name)} = "
74+
yield from self.iterencode(getattr(value, arg_name))
75+
first = False
76+
yield ")"
6677
else:
6778
yield from super().iterencode(value)
6879

0 commit comments

Comments
 (0)