glean / mozilla.telemetry.glean.private / CustomDistributionMetricType


data class CustomDistributionMetricType : HistogramBase

This implements the developer facing API for recording custom distribution metrics.

Custom distributions are histograms with the following parameters that are settable on a per-metric basis:

    - `rangeMin`/`rangeMax`: The minimum and maximum values
    - `bucketCount`: The number of histogram buckets
    - `histogramType`: Whether the bucketing is linear or exponential

This metric exists primarily for backward compatibility with histograms in legacy (pre-Glean) telemetry, and its use is not recommended for newly-created 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.



CustomDistributionMetricType(disabled: Boolean, category: String, lifetime: Lifetime, name: String, sendInPings: List<String>, rangeMin: Long, rangeMax: Long, bucketCount: Int, histogramType: HistogramType)

The public constructor used by automatically generated metrics.

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

This implements the developer facing API for recording custom distribution metrics.



fun accumulateSamples(samples: LongArray): Unit

Accumulates the provided samples in the metric.


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()): DistributionData

Returns the stored value for testing purposes only.


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

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