glean / mozilla.telemetry.glean.private / DatetimeMetricType

DatetimeMetricType

class DatetimeMetricType

This implements the developer facing API for recording datetime metrics.

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

Constructors

<init>

DatetimeMetricType(disabled: Boolean, category: String, lifetime: Lifetime, name: String, sendInPings: List<String>, timeUnit: TimeUnit = TimeUnit.Minute)

The public constructor used by automatically generated metrics.

Functions

set

fun set(value: Date = Date()): Unit

Set a datetime value, truncating it to the metric's resolution.

testGetNumRecordedErrors

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

Returns the number of errors recorded for the given metric.

testGetValue

fun testGetValue(pingName: String = sendInPings.first()): Date

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.

testGetValueAsString

fun testGetValueAsString(pingName: String = sendInPings.first()): String

Returns the string representation of 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.

testHasValue

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

Tests whether a value is stored for the metric 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.