Debian Codegraph @

third_party/rust/glean-core/README.md

raw
1 # Glean SDK
2
3 The `Glean SDK` is a modern approach for a Telemetry library and is part of the [Glean project](https://docs.telemetry.mozilla.org/concepts/glean/glean.html).
4
5 ## `glean-core`
6
7 This library provides the core functionality of the Glean SDK, including implementations of all metric types, the ping serializer and the storage layer.
8 It's used in all platform-specific wrappers.
9
10 It's not intended to be used by users directly.
11 Each supported platform has a specific Glean package with a nicer API.
12 A nice Rust API will be provided by the [Glean](https://crates.io/crates/glean) crate.
13
14 ## Documentation
15
16 All documentation is available online:
17
18 * [The Glean SDK Book][book]
19 * [API documentation][apidocs]
20
21 [book]: https://mozilla.github.io/glean/
22 [apidocs]: https://mozilla.github.io/glean/docs/glean_core/index.html
23
24 ## Usage
25
26 ```rust
27 use glean_core::{Glean, Configuration, CommonMetricData, metrics::*};
28 let cfg = Configuration {
29 data_path: "/tmp/glean".into(),
30 application_id: "glean.sample.app".into(),
31 upload_enabled: true,
32 max_events: None,
33 };
34 let mut glean = Glean::new(cfg).unwrap();
35 let ping = PingType::new("sample", true, true, vec![]);
36 glean.register_ping_type(&ping);
37
38 let call_counter: CounterMetric = CounterMetric::new(CommonMetricData {
39 name: "calls".into(),
40 category: "local".into(),
41 send_in_pings: vec!["sample".into()],
42 ..Default::default()
43 });
44
45 call_counter.add(&glean, 1);
46
47 glean.submit_ping(&ping, None).unwrap();
48 ```
49
50 ## License
51
52 This Source Code Form is subject to the terms of the Mozilla Public
53 License, v. 2.0. If a copy of the MPL was not distributed with this
54 file, You can obtain one at http://mozilla.org/MPL/2.0/