glean / mozilla.telemetry.glean.private / StringListMetricType

StringListMetricType

class StringListMetricType

This implements the developer facing API for recording string list 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.

The string list API only exposes the add and set methods, which takes care of validating the input data and making sure that limits are enforced.

The internal constructor is only used by LabeledMetricType directly.

Constructors

<init>

StringListMetricType(disabled: Boolean, category: String, lifetime: Lifetime, name: String, sendInPings: List<String>)

The public constructor used by automatically-generated metrics.

StringListMetricType(handle: Long, disabled: Boolean, sendInPings: List<String>)

This implements the developer facing API for recording string list metrics.

Functions

add

fun add(value: String): Unit

Appends a string value to one or more string list metric stores. If the string exceeds the maximum string length or if the list exceeds the maximum length it will be truncated.

set

fun set(value: List<String>): Unit

Sets a string list to one or more metric stores. If any string exceeds the maximum string length or if the list exceeds the maximum length it will be truncated.

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()): List<String>

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.

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.