glean/glean-core/build
Travis Long b48898e1db Update glean_parser to v6.1.2 2022-07-29 10:47:01 +02:00
..
src Update glean_parser to v6.1.2 2022-07-29 10:47:01 +02:00
Cargo.toml Update glean_parser to v6.1.2 2022-07-29 10:47:01 +02:00
LICENSE
README.md

README.md

Glean SDK

The Glean SDK is a modern approach for a Telemetry library and is part of the Glean project.

glean-build

This library provides a code generator for use in build.rs.

Documentation

The Glean SDK documentation is available online:

The glean-build API is documented online:

Requirements

  • Python 3
  • pip

Usage

Add glean-build as a build dependency to your project in Cargo.toml:

[build-dependencies]
glean-build = "6.0.1"

Then add a build.rs file next to your Cargo.toml and call the builder:

use glean_build::Builder;

fn main() {
    Builder::default()
        .file("metrics.yaml")
        .generate()
        .expect("Error generating Glean Rust bindings");
}

In your code add the following to include the generated code:

mod metrics {
    include!(concat!(env!("OUT_DIR"), "/glean_metrics.rs"));
}

You can then access your metrics and pings directly by name within the metrics module.

License

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/