glean / mozilla.telemetry.glean.private / EventMetricType


class EventMetricType<ExtraKeysEnum : Enum<ExtraKeysEnum>, ExtraObject : EventExtras>

This implements the developer facing API for recording events.

Instances of this class type are automatically generated by the parsers at built time, allowing developers to record events that were previously registered in the metrics.yaml file.

The Events API only exposes the record method, which takes care of validating the input data and making sure that limits are enforced.



EventMetricType(disabled: Boolean, category: String, lifetime: Lifetime, name: String, sendInPings: List<String>, allowedExtraKeys: List<String>? = null)

The public constructor used by automatically generated metrics.



fun record(extra: Map<ExtraKeysEnum, String>? = null): Unit
fun record(extra: ExtraObject): Unit

Record an event by using the information provided by the instance of this class.


fun testGetNumRecordedErrors(errorType: ErrorType, pingName: String = sendInPings.first()): Int

Returns the number of errors recorded for the given metric.


fun testGetValue(pingName: String = sendInPings.first()): List<RecordedEventData>

Returns the stored value for testing purposes only. This function will attempt to await the last task (if any) writing to the the metric's storage engine before returning a value.


fun testHasValue(pingName: String = sendInPings.first()): Boolean

Tests whether a value is stored for the metric for testing purposes only.