How the Glean SDK Manages Cross-Platform Firefox Telemetry

This article provides an overview of how Mozilla's Glean SDK standardizes and manages structured telemetry collection across both desktop and mobile versions of the Firefox web browser. By utilizing a unified cross-platform architecture, strict schema definitions, multi-process communication layers, and reliable local database storage, Glean ensures consistent and privacy-preserving data collection regardless of the underlying operating system.

A Unified Rust Core

The Glean SDK achieves cross-platform consistency through a shared core library written in Rust, known as glean-core. Rather than maintaining separate telemetry implementations and logic for Android, iOS, Windows, macOS, and Linux, Mozilla uses this single Rust library to handle data validation, storage, and serialization.

Language-specific bindings act as thin wrappers over this Rust core. On mobile, Firefox uses Kotlin bindings for Android and Swift bindings for iOS. On desktop, Firefox utilizes C++, JavaScript, and Rust bindings. Because the underlying logic is identical across all platforms, a metric recorded on an iPhone behaves the exact same way as a metric recorded on a Windows PC.

Declarative Metric Definitions

To ensure telemetry is strictly structured, Glean requires developers to define all data points in YAML registry files (metrics.yaml and pings.yaml) before writing any data collection code.

During the browser's build process, a tool called glean_parser reads these YAML files, validates them against strict schemas, and automatically generates type-safe API code for the target platform. Glean enforces the use of specific, predefined metric types—such as counters, timing distributions, booleans, and events. This strict typing prevents developers from collecting unstructured data and ensures that data analysts know the exact shape and behavior of the incoming telemetry.

Multi-Process Handling on Desktop

While mobile browsers operate within tightly controlled OS application lifecycles, Firefox Desktop uses a complex multi-process architecture (Project Fission) that isolates web content into numerous sandboxed child processes.

To manage this, Mozilla uses an integration layer called "Firefox on Glean" (FOG). Because child processes do not have direct access to the local disk for security reasons, FOG provides Inter-Process Communication (IPC) mechanisms. When a metric is recorded in a content or GPU process on desktop, FOG safely batches and funnels that data back to the main parent process, which then passes the data into the Glean Rust core.

Local Storage and Ping Assembly

When Firefox records a metric on either desktop or mobile, the Glean SDK validates the input and immediately writes it to a local key-value database (using LMDB) on the user's device. Persisting data directly to the disk ensures that telemetry is not lost if the browser crashes or the mobile operating system abruptly terminates the app.

Glean organizes these stored metrics into structured payloads called "pings." Rather than sending data continuously, Glean batches metrics into specific pings that serve different purposes:

  • Baseline Ping: Captures basic session duration and activity, triggered when the browser goes to the background or closes.
  • Metrics Ping: A comprehensive daily snapshot of all collected metrics.
  • Events Ping: Tracks specific user interactions in chronological order.
  • Custom Pings: Defined by engineers for specialized browser features.

When a trigger condition is met—such as a daily timer expiring on desktop or a user minimizing the app on mobile—Glean reads the local database, assembles the relevant metrics into a standardized JSON payload, attaches common metadata (like OS version and locale), and queues the ping for upload.

Network Transmission and Privacy Controls

The Glean SDK does not handle network requests inside its Rust core. Instead, it hands the serialized JSON ping back to the host application's native networking stack (such as Viaduct/Necko on desktop and Android, or URLSession on iOS). This allows the browser to respect platform-specific constraints, such as mobile battery-saving modes and background data limits.

Finally, the Glean SDK centrally manages user privacy choices. If a user opts out of telemetry in the Firefox settings on any device, Glean immediately halts all metric recording, wipes the local LMDB storage, and generates a specialized deletion-request ping. This final ping instructs Mozilla's ingestion servers to purge all previously collected data associated with that installation's client ID.