glean / mozilla.telemetry.glean.private / LabeledMetricType

LabeledMetricType

class LabeledMetricType<T>

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

Unlike most metric types, LabeledMetricType does not have its own corresponding storage, but records metrics for the underlying metric type T in the storage for that type. The only difference is that labeled metrics are stored with the special key $category.$name/$label. The collect method knows how to pull these special values back out of the individual metric storage and rearrange them correctly in the ping.

Constructors

<init>

LabeledMetricType(disabled: Boolean, category: String, lifetime: Lifetime, name: String, labels: Set<String>? = null, sendInPings: List<String>, subMetric: T)

This implements the developer facing API for labeled metrics.

Functions

get

operator fun get(label: String): T

Get the specific metric for a given label.

operator fun get(labelIndex: Int): T

Get the specific metric for a given label index.

testGetNumRecordedErrors

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

Returns the number of errors recorded for the given metric.