Consider improving the instrumentation of counts of two cases (like boolean histograms, labeled_counter)
Categories
(Data Platform and Tools :: Glean: SDK, enhancement, P4)
Tracking
(Not tracked)
People
(Reporter: chutten, Unassigned)
References
Details
While migrating Histograms of kind: boolean in Firefox Desktop we noticed just how often people want to instrument two related counts: one for when something is, and one for when something isn't.
At present, the Glean SDK has two decent encodings of this. A labeled_counter
with two labels
, or a rate
(though instead of it being count_of_true
and count_of_false
, you need arithmetic to get count_of_false = numerator - denominator
).
So far so good... except that the ergonomics of labeled_counter
metrics are still a little... verbose: mozilla::glean::a_category::a_metric.Get("true"_ns").Add(1);
or, for performance, mozilla::glean::a_category::a_metric.EnumGet(mozilla::glean::a_category::AMetricLabel::eTrue).Add(1)
. Especially since the pattern is almost certainly:
bool someBool;
mozilla::glean::a_category::a_metric.EnumGet(someBool ? mozilla::glean::a_category::AMetricLabel::eTrue : mozilla::glean::a_category::AMetricLabel::eFalse).Add(1);
And JS isn't much better.
Is there aught we can do to make this common case better? Convenience methods for converting from bools to enums or static label strings? Reifying the submetrics directly for labeled metrics with static labels (so you could mozilla::glean::a_category::a_metric::eTrue.Add(1);
directly)?
There's basically 100 of these cases in Firefox Desktop, so it might be worth making this nicer.
Updated•27 days ago
|
Description
•