Used to record a single non-negative integer value. For example, the width of the display in pixels.
Note: Quantities are currently only allowed for GeckoView metrics (the
gecko_datapointparameter is present) and thus have only a Kotlin API.
Say you're adding a new quantity for the width of the display in pixels. First you need to add an entry for the quantity to the
gfx: display_width: type: quantity description: > The width of the display, in pixels. unit: pixels gecko_datapoint: DISPLAY_W_PIXELS ...
Note that quantities have a required
unit parameter, which is a free-form string for documentation purposes.
import org.mozilla.yourApplication.GleanMetrics.Gfx Gfx.displayWidth.set(width)
There are test APIs available too:
import org.mozilla.yourApplication.GleanMetrics.Gfx // Was anything recorded? assertTrue(Gfx.displayWidth.testHasValue()) // Does the quantity have the expected value? assertEquals(6, Gfx.displayWidth.testGetValue()) // Did it record an error due to a negative value? assertEquals(1, Gfx.displayWidth.testGetNumRecordedErrors(ErrorType.InvalidValue))
Quantities must be non-negative integers.
Quantities are only available for metrics that come from Gecko.
- What is the width of the display, in pixels?
invalid_value: If a negative value is passed in.