android-components / mozilla.components.service.glean.private / TimespanMetricType

TimespanMetricType

data class TimespanMetricType : CommonMetricData (source)

This implements the developer facing API for recording timespans.

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 timespan API exposes the start, stop and cancel methods.

Constructors

Name Summary
<init> TimespanMetricType(disabled: Boolean, category: String, lifetime: Lifetime, name: String, sendInPings: List<String>, timeUnit: TimeUnit)
This implements the developer facing API for recording timespans.

Properties

Name Summary
category val category: String
disabled val disabled: Boolean
lifetime val lifetime: Lifetime
name val name: String
sendInPings val sendInPings: List<String>
timeUnit val timeUnit: TimeUnit

Inherited Properties

Name Summary
identifier open val identifier: String

Functions

Name Summary
cancel fun cancel(): Unit
Abort a previous start call. No error is recorded if no start was called.
setRawNanos fun setRawNanos(elapsedNanos: Long): Unit
Explicitly set the timespan value, in nanoseconds.
start fun start(): Unit
Start tracking time for the provided metric. This records an error if it’s already tracking time (i.e. start was already called with no corresponding stop): in that case the original start time will be preserved.
stop fun stop(): Unit
Stop tracking time for the provided metric. Sets the metric to the elapsed time.This will record an error if no start was called.
testGetValue fun testGetValue(pingName: String = sendInPings.first()): Long
Returns the stored value for testing purposes only, in the metric’s time unit.
testHasValue fun testHasValue(pingName: String = sendInPings.first()): Boolean
Tests whether a value is stored for the metric for testing purposes only

Inherited Functions

Name Summary
shouldRecord open fun shouldRecord(logger: Logger): Boolean