Closed Bug 1762859 Opened 3 years ago Closed 1 year ago

Consider not recording an error when adding <= 0 to a counter metric, or making the error optional

Categories

(Data Platform and Tools :: Glean: SDK, defect, P1)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: brizental, Assigned: chutten)

Details

Attachments

(1 file)

Like via a new YAML property? non_positive_sample_behaviour: {error_on_zero_or_negative|error_on_negative|ignore} ? (Default: error_on_zero_or_negative)

I did no think too much about it, but I thought maybe an optional argument for add. Needs more consideration though and a YAML property could be a better solution.

Whiteboard: [telemetry:glean-rs:m?]

I'm leaning towards

  1. Still recording an Invalid State on < 0 because that seems useful
  2. No more error on = 0

We couldn't come up with arguments for treating add(0) as an error that stand up to how writing if (value > 0) { Glean.myCategory.myCounter.add(value); } is much worse.

Suppressing on < 0 seems like an argument to finally rev the API to only accept unsigned numbers (forbidding errors is better than reporting errors) which, though I'm in favour of, may require more conversation than just this bug.

And this small change has nice effects on types, making the use of this API more straightforward for unsigned types. (Though we still have an ergonomics squeak with the narrowing conversion from u32 to i32 to make it fit through the udl. Again, we're not talking about scoping in a revision to the API to make it unsigned.)

ni?Travis to make a ruling as Glean SDK Tech Lead.

Flags: needinfo?(tlong)

I agree with both 1 & 2.

  • Let's keep an error if a negative value is recorded via add()
  • Let's remove the error if add(0)

One question I have regards how we now send null in the case a counter is zero. I wonder if we also need to revisit this thinking since it might be surprising if after add(0) is called, the resulting metric is null in the transmitted ping.

Flags: needinfo?(tlong)

I'm happiest if we keep "should we change our minds about whether 0 is meaningfully different from null or "absent"" out of scope for this bug.

Assignee: nobody → chutten
Status: NEW → ASSIGNED
Priority: P3 → P1

Fair enough, we can always file a bug about the treatment of "0" and deal with that in a later iteration, if we even decide to change it.

Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: