Crate glean_core

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


pub use crate::metrics::DistributionData;
pub use crate::upload::PingUploadTask;


The different metric types supported by the Glean SDK to handle data.
Ping collection, assembly & submission.
Storage snapshotting.
API definitions for the different metric types supported by the Glean SDK.
Manages the pending pings queue and directory.


A boolean metric.
Metrics included in every ping as client_info.
The common set of data shared across all different metric types.
A counter metric.
A custom distribution metric.
Representation of a date, time and timezone.
A datetime metric.
A Denominator metric (a kind of count shared among Rate metrics).
A specialized Error type for this crate’s operations.
An event metric.
The object holding meta information about a Glean instance.
Configuration for Glean
A labeled metric.
A memory distribution metric.
Developer-facing API for recording rate metrics with external denominators.
An object metric.
How to specify the rate at which pings may be uploaded before they are throttled.
Represents a request to upload a ping.
Stores information about a ping.
A quantity metric.
A rate value as given by its numerator and denominator.
A rate metric.
Represents the recorded data for a single event.
Deserialized experiment data.
A string list metric.
A string metric.
A text metric.
Identifier for a running timer.
A timespan metric.
A timing distribution metric.
A URL metric.
An UUID metric.


An error returned from callbacks.
A list enumerating the categories of errors in this crate.
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 metric data needed to construct inner submetrics.
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).
The result of an attempted ping upload.
Communication back whether the uploader loop should continue.


Trait for metrics that can be nested inside a labeled metric.
A callback handler that receives the base identifier of recorded events The identifier is in the format: <category>.<name>
A callback object used to trigger actions on the foreign-language side.


Returns a timestamp corresponding to “now” with millisecond precision.
Sets a remote configuration to override metrics’ default enabled/disabled state
Initialize the logging system based on the target platform. This ensures that logging is shown when executing the Glean SDK unit tests.
Initialize the logging system to send JSON messages to a file descriptor (Unix) or file handle (Windows).
Get the next upload task
Performs the collection/cleanup operations required by becoming active.
Performs the collection/cleanup operations required by becoming inactive.
Initializes Glean.
Creates and initializes a new Glean object for use in a subprocess.
Asks the database to persist ping-lifetime data to disk. Probably expensive to call. Only has effect when Glean is configured with delay_ping_lifetime_io: true. If Glean hasn’t been initialized this will dispatch and return Ok(()), otherwise it will block until the persist is done and return its Result.
Processes the response from an attempt to upload a ping.
EXPERIMENTAL: Register a listener object to recieve notifications of event recordings.
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.
Set an experimentation identifier dynamically.
Sets the log pings debug option.
Sets source tags.
Sets whether upload is enabled or not.
Shuts down Glean in an orderly fashion.
Collect and submit a ping for eventual upload by name.
Collect and submit a ping (by its name) for eventual upload, synchronously.
TEST ONLY FUNCTION. Returns the RecordedExperiment for the given experiment_id or None if the id isn’t found.
TEST ONLY FUNCTION. Gets stored experimentation id annotation.
Unregister an event listener from recieving notifications.
TEST ONLY FUNCTION Waits on all the glean.init threads’ join handles.
Shuts down Glean in an orderly fashion.
Gets the number of recorded errors for the given metric and error type.

Type Definitions

A labeled boolean.
A labeled counter.
A labeled custom_distribution.
A labeled memory_distribution.
A labeled string.
A labeled timing_distribution.
A specialized Result type for this crate’s operations.