Crate glean

source · []
Expand description

Glean is a modern approach for recording and sending Telemetry data.

It’s in use at Mozilla.

All documentation can be found online:

The Glean SDK Book


Initialize Glean, register a ping and then send it.

let cfg = Configuration {
    data_path: "/tmp/data".into(),
    application_id: "org.mozilla.glean_core.example".into(),
    upload_enabled: true,
    max_events: None,
    delay_ping_lifetime_io: false,
    channel: None,
    server_endpoint: None,
    uploader: None,
    use_core_mps: false,
glean::initialize(cfg, ClientInfoMetrics::unknown());

let prototype_ping = PingType::new("prototype", true, true, vec!());




Handling the Glean upload logic.

The different metric types supported by the Glean SDK to handle data.

API definitions for the different metric types supported by the Glean SDK.


Metrics included in every ping as client_info.

The common set of data shared across all different metric types.

The Glean configuration.

A snapshot of all buckets and the accumulated sum of a distribution.

A specialized Error type for this crate’s operations.

The object holding meta information about a Glean instance.

Represents the recorded data for a single event.

Deserialized experiment data.


The possible error types for metric recording. Note: the cases in this enum must be kept in sync with the ones in the platform-specific code (e.g. ErrorType.kt) and with the metrics in the registry files.

Different kinds of histograms.

The supported metrics’ lifetimes.

Different resolutions supported by the memory related metric types (e.g. MemoryDistributionMetric).

Different resolutions supported by the time related metric types (e.g. DatetimeMetric).


Returns a timestamp corresponding to “now” with millisecond precision.

Performs the collection/cleanup operations required by becoming active.

Performs the collection/cleanup operations required by becoming inactive.

Creates and initializes a new Glean object.

Dispatches a request to the database to persist ping-lifetime data to disk.

Unblock the global dispatcher to start processing queued tasks.

Sets a debug view tag.

Indicate that an experiment is running. Glean will then add an experiment annotation to the environment which is sent with pings. This infomration is not persisted between runs.

Indicate that an experiment is no longer running.

Sets the log pings debug option.

Sets source tags.

Sets whether upload is enabled or not.

Shuts down Glean in an orderly fashion.

Collects and submits a ping for eventual uploading by name.

TEST ONLY FUNCTION. Returns the RecordedExperimentData for the given experiment_id or panics if the id isn’t found.

TEST ONLY FUNCTION. Checks if an experiment is currently active.

TEST ONLY FUNCTION. Resets the Glean state and triggers init again.

Type Definitions

A datetime type.

A specialized Result type for this crate’s operations.

Identifier for a running timer.