Backed out changeset aba2a1dc6802 (bug 1816454) for causing PNGEncoder related build bustages. CLOSED TREE

This commit is contained in:
Stanca Serban 2023-02-27 16:42:40 +02:00
parent 93a42ef35c
commit 8917a2896e
59 changed files with 768 additions and 1402 deletions

12
Cargo.lock generated
View File

@ -66,9 +66,9 @@ checksum = "85965b6739a430150bdd138e2374a98af0c3ee0d030b3bb7fc3bddff58d0102e"
[[package]] [[package]]
name = "android_logger" name = "android_logger"
version = "0.12.0" version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "037f3e1da32ddba7770530e69258b742c15ad67bdf90e5f6b35f4b6db9a60eb7" checksum = "8619b80c242aa7bd638b5c7ddd952addeecb71f69c75e33f1d47b2804f8f883a"
dependencies = [ dependencies = [
"android_log-sys", "android_log-sys",
"env_logger 0.10.0", "env_logger 0.10.0",
@ -2307,9 +2307,9 @@ dependencies = [
[[package]] [[package]]
name = "glean" name = "glean"
version = "52.3.0" version = "52.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa4d34f9ae46bd3e68c5bb672762e7391843daedd609506a70b6b35ac6fea051" checksum = "3dea54c0198181ff3bd8c7d39bdc69f22a4c0504da5dd9138666edef084e26be"
dependencies = [ dependencies = [
"chrono", "chrono",
"crossbeam-channel", "crossbeam-channel",
@ -2327,9 +2327,9 @@ dependencies = [
[[package]] [[package]]
name = "glean-core" name = "glean-core"
version = "52.3.0" version = "52.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "699ab3d674e2618298111987c0053735ef7a531d09264a3aa7d496f5ac2247d6" checksum = "01c3b0c688d31dbe58dd799d771d4ab60d9a20932fa0eac80dbb08f20149f36b"
dependencies = [ dependencies = [
"android_logger", "android_logger",
"bincode", "bincode",

View File

@ -36,7 +36,7 @@ allprojects {
topsrcdir = gradle.mozconfig.topsrcdir topsrcdir = gradle.mozconfig.topsrcdir
topobjdir = gradle.mozconfig.topobjdir topobjdir = gradle.mozconfig.topobjdir
gleanVersion = "52.3.0" gleanVersion = "52.2.0"
if (gleanVersion != getRustVersionFor("glean")) { if (gleanVersion != getRustVersionFor("glean")) {
throw new StopExecutionException("Mismatched Glean version, expected: ${gleanVersion}," + throw new StopExecutionException("Mismatched Glean version, expected: ${gleanVersion}," +
" found ${getRustVersionFor("glean")}") " found ${getRustVersionFor("glean")}")

886
gfx/wr/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -52,7 +52,7 @@ svg_fmt = "0.4"
tracy-rs = "0.1.2" tracy-rs = "0.1.2"
derive_more = { version = "0.99", default-features = false, features = ["add_assign"] } derive_more = { version = "0.99", default-features = false, features = ["add_assign"] }
etagere = "0.2.6" etagere = "0.2.6"
glean = "52.3.0" glean = "52.2.0"
firefox-on-glean = { version = "0.1.0", optional = true } firefox-on-glean = { version = "0.1.0", optional = true }
swgl = { path = "../swgl", optional = true } swgl = { path = "../swgl", optional = true }
topological-sort = "0.1" topological-sort = "0.1"

View File

@ -25,7 +25,7 @@ tracy-rs = "0.1.2"
log = "0.4" log = "0.4"
lazy_static = "1" lazy_static = "1"
fxhash = "0.2.1" fxhash = "0.2.1"
glean = { version = "52.3.0", optional = true } glean = { version = "52.0.0", optional = true }
firefox-on-glean = { version = "0.1.0", optional = true } firefox-on-glean = { version = "0.1.0", optional = true }
serde = { optional = true, version = "1.0", features = ["serde_derive"] } serde = { optional = true, version = "1.0", features = ["serde_derive"] }

View File

@ -136,7 +136,7 @@ pth:xpcom/geckoprocesstypes_generator
pth:xpcom/idl-parser pth:xpcom/idl-parser
# glean-sdk may not be installable if a wheel isn't available # glean-sdk may not be installable if a wheel isn't available
# and it has to be built from source. # and it has to be built from source.
pypi-optional:glean-sdk==52.3.0:telemetry will not be collected pypi-optional:glean-sdk==52.2.0:telemetry will not be collected
# Mach gracefully handles the case where `psutil` is unavailable. # Mach gracefully handles the case where `psutil` is unavailable.
# We aren't (yet) able to pin packages in automation, so we have to # We aren't (yet) able to pin packages in automation, so we have to
# support down to the oldest locally-installed version (5.4.2). # support down to the oldest locally-installed version (5.4.2).

View File

@ -1,22 +1,6 @@
# cargo-vet audits file # cargo-vet audits file
[[wildcard-audits.glean]]
who = "Chris H-C <chutten@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 48
start = "2020-11-10"
end = "2024-02-24"
notes = "The Glean SDKs are maintained by the Glean Team at Mozilla."
[[wildcard-audits.glean-core]]
who = "Chris H-C <chutten@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 48
start = "2019-09-24"
end = "2024-02-24"
notes = "The Glean SDKs are maintained by the Glean Team at Mozilla."
[[audits.aa-stroke]] [[audits.aa-stroke]]
who = "Lee Salzman <lsalzman@mozilla.com>" who = "Lee Salzman <lsalzman@mozilla.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"
@ -50,12 +34,6 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"
delta = "0.11.1 -> 0.11.3" delta = "0.11.1 -> 0.11.3"
[[audits.android_logger]]
who = "Chris H-C <chutten@mozilla.com>"
criteria = "safe-to-deploy"
delta = "0.11.3 -> 0.12.0"
notes = "Small wrapper crate. This update fixes log level filtering."
[[audits.android_system_properties]] [[audits.android_system_properties]]
who = "Nicolas Silva <nical@fastmail.com>" who = "Nicolas Silva <nical@fastmail.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"
@ -996,6 +974,184 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"
delta = "0.2.7 -> 0.2.8" delta = "0.2.7 -> 0.2.8"
[[audits.glean]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
version = "50.1.0"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean]]
who = "Travis Long <tlong@mozilla.com>"
criteria = "safe-to-deploy"
version = "50.1.2"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
version = "51.1.0"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean]]
who = "Chris H-C <chutten@mozilla.com>"
criteria = "safe-to-deploy"
version = "51.7.0"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean]]
who = "Chris H-C <chutten@mozilla.com>"
criteria = "safe-to-deploy"
version = "51.8.1"
notes = "Maintained by the Glean Team at Mozilla"
[[audits.glean]]
who = "Chris H-C <chutten@mozilla.com>"
criteria = "safe-to-deploy"
version = "51.8.2"
notes = "Maintained by the Glean Team at Mozilla."
[[audits.glean]]
who = "Chris H-C <chutten@mozilla.com>"
criteria = "safe-to-deploy"
version = "52.0.0"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "50.1.2 -> 50.1.3"
notes = "Unchanged from last version"
[[audits.glean]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "50.1.3 -> 51.0.1"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "51.1.0 -> 51.2.0"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean]]
who = "Perry McManis <pmcmanis@mozilla.com>"
criteria = "safe-to-deploy"
delta = "51.2.0 -> 51.4.0"
[[audits.glean]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "51.4.0 -> 51.5.0"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "51.7.0 -> 51.8.0"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "52.0.0 -> 52.0.1"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "52.0.1 -> 52.2.0"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean-core]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
version = "50.1.0"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean-core]]
who = "Travis Long <tlong@mozilla.com>"
criteria = "safe-to-deploy"
version = "50.1.2"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean-core]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
version = "51.1.0"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean-core]]
who = "Chris H-C <chutten@mozilla.com>"
criteria = "safe-to-deploy"
version = "51.7.0"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean-core]]
who = "Chris H-C <chutten@mozilla.com>"
criteria = "safe-to-deploy"
version = "51.8.1"
notes = "Maintained by the Glean Team at Mozilla"
[[audits.glean-core]]
who = "Chris H-C <chutten@mozilla.com>"
criteria = "safe-to-deploy"
version = "51.8.2"
notes = "Maintained by the Glean Team at Mozilla."
[[audits.glean-core]]
who = "Chris H-C <chutten@mozilla.com>"
criteria = "safe-to-deploy"
version = "52.0.0"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean-core]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "50.1.2 -> 50.1.3"
notes = "Bug fix release with minimal changes, changes done by myself"
[[audits.glean-core]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "50.1.3 -> 51.0.1"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean-core]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "51.1.0 -> 51.2.0"
notes = "Bug fix release with minimal changes, changes done by myself"
[[audits.glean-core]]
who = "Perry McManis <pmcmanis@mozilla.com>"
criteria = "safe-to-deploy"
delta = "51.2.0 -> 51.4.0"
[[audits.glean-core]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "51.4.0 -> 51.5.0"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean-core]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "51.7.0 -> 51.8.0"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean-core]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "52.0.0 -> 52.0.1"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glean-core]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "52.0.1 -> 52.2.0"
notes = "Maintained by the Glean team at Mozilla"
[[audits.glob]] [[audits.glob]]
who = "Mike Hommey <mh+mozilla@glandium.org>" who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"

View File

@ -1,20 +1,6 @@
# cargo-vet imports lock # cargo-vet imports lock
[[publisher.glean]]
version = "52.3.0"
when = "2023-02-23"
user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.glean-core]]
version = "52.3.0"
when = "2023-02-23"
user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[audits.bytecodealliance.audits.arbitrary]] [[audits.bytecodealliance.audits.arbitrary]]
who = "Nick Fitzgerald <fitzgen@gmail.com>" who = "Nick Fitzgerald <fitzgen@gmail.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"

View File

@ -1 +1 @@
{"files":{"CHANGELOG.md":"66faf0eef7c262a90a0538248c0753b5bb7f6f38df086a3701db1590cc0e81a3","Cargo.toml":"35882b3da778c3a4464967f6142579b1378a4ab9ff83adebb151a606c5fdd9ed","LICENSE-APACHE":"99938c5864dd33decb62ab20fd883a9b00181d768ae887a4f19b2d0015c41dc9","LICENSE-MIT":"35043211d1b7be8f7e3f9cad27d981f2189ba9a39d9527b275b3c9740298dfe2","README.md":"dbdb2a11c4a49ec21259d611af2de6123fa9b3f467950eb7a5af163f8aea556b","src/lib.rs":"f820afaf0c15160756128018fb6eac94f74a8cf6359168346354d120c1204532","tests/config_log_level.rs":"61f12ee69f0a7e0e6c2b224d4b678f384ca0ee75122e62c01a9f75dbd9ba4437","tests/default_init.rs":"e5c77dbcf3dc2d9e21e5c48c190e6cdcdea7d8eecea8c8ce513ca98223c46b49","tests/multiple_init.rs":"b5fa06a0b92843227ecbb6285bdf7ab826412fd2fe11fac8b1fd68a7354fd3ee"},"package":"037f3e1da32ddba7770530e69258b742c15ad67bdf90e5f6b35f4b6db9a60eb7"} {"files":{"CHANGELOG.md":"bed2dedbff30c278a6f8de0e014a5fb4538b74b711dc733d62199cab0b4c84aa","Cargo.toml":"b4200b3217cac7b6ce6947913e45f8886456a4aca19aa7e7a28b317d11d36e6f","LICENSE-APACHE":"99938c5864dd33decb62ab20fd883a9b00181d768ae887a4f19b2d0015c41dc9","LICENSE-MIT":"35043211d1b7be8f7e3f9cad27d981f2189ba9a39d9527b275b3c9740298dfe2","README.md":"bf2e6227790edeb5959c2be250b71d1a197a3a344dc5fc1638fbb39c73bdfd21","src/lib.rs":"bcee83b2bd47d8b795a7aca2bc354a4463a13068cbfe92918ddc76c93861e5f5","tests/config_log_level.rs":"dbe26e82c497031f47804ed59dfcdb5d09af7354591f90ea89b46315e7d2edc9","tests/default_init.rs":"e5c77dbcf3dc2d9e21e5c48c190e6cdcdea7d8eecea8c8ce513ca98223c46b49","tests/multiple_init.rs":"42adfe70b2f951a3b3f051235709013124df613a7967ca5bad998fc5356b8b9f"},"package":"8619b80c242aa7bd638b5c7ddd952addeecb71f69c75e33f1d47b2804f8f883a"}

View File

@ -6,28 +6,6 @@ All user visible changes to this project will be documented in this file. This p
## [0.12.0] · 2023-01-19
[0.12.0]: /../../tree/v0.12.0
[Diff](/../../compare/v0.11.3...v0.12.0)
### Added
- `Config::with_max_level()` method to filters logs via `log::LevelFilter`. ([#62])
### Deprecated
- `Config::with_min_level()` method accepting `log::Level`. ([#62])
### Fixed
- Incorrect logs level filtering. ([#62])
[#62]: /../../pull/62
## [0.11.3] · 2022-12-20 ## [0.11.3] · 2022-12-20
[0.11.3]: /../../tree/v0.11.3 [0.11.3]: /../../tree/v0.11.3

View File

@ -11,7 +11,7 @@
[package] [package]
name = "android_logger" name = "android_logger"
version = "0.12.0" version = "0.11.3"
authors = ["The android_logger Developers"] authors = ["The android_logger Developers"]
description = """ description = """
A logging implementation for `log` which hooks to android log output. A logging implementation for `log` which hooks to android log output.

View File

@ -22,13 +22,13 @@ Example of initialization on activity creation, with log configuration:
#[macro_use] extern crate log; #[macro_use] extern crate log;
extern crate android_logger; extern crate android_logger;
use log::LevelFilter; use log::Level;
use android_logger::{Config,FilterBuilder}; use android_logger::{Config,FilterBuilder};
fn native_activity_create() { fn native_activity_create() {
android_logger::init_once( android_logger::init_once(
Config::default() Config::default()
.with_max_level(LevelFilter::Trace) // limit log level .with_min_level(Level::Trace) // limit log level
.with_tag("mytag") // logs will show under mytag tag .with_tag("mytag") // logs will show under mytag tag
.with_filter( // configure messages for specific crate .with_filter( // configure messages for specific crate
FilterBuilder::new() FilterBuilder::new()
@ -47,13 +47,12 @@ To allow all logs, use the default configuration with min level Trace:
#[macro_use] extern crate log; #[macro_use] extern crate log;
extern crate android_logger; extern crate android_logger;
use log::LevelFilter; use log::Level;
use android_logger::Config; use android_logger::Config;
fn native_activity_create() { fn native_activity_create() {
android_logger::init_once( android_logger::init_once(
Config::default().with_max_level(LevelFilter::Trace), Config::default().with_min_level(Level::Trace));
);
} }
``` ```

View File

@ -13,13 +13,13 @@
//! #[macro_use] extern crate log; //! #[macro_use] extern crate log;
//! extern crate android_logger; //! extern crate android_logger;
//! //!
//! use log::LevelFilter; //! use log::Level;
//! use android_logger::Config; //! use android_logger::Config;
//! //!
//! /// Android code may not have obvious "main", this is just an example. //! /// Android code may not have obvious "main", this is just an example.
//! fn main() { //! fn main() {
//! android_logger::init_once( //! android_logger::init_once(
//! Config::default().with_max_level(LevelFilter::Trace), //! Config::default().with_min_level(Level::Trace),
//! ); //! );
//! //!
//! debug!("this is a debug {}", "message"); //! debug!("this is a debug {}", "message");
@ -36,13 +36,13 @@
//! #[macro_use] extern crate log; //! #[macro_use] extern crate log;
//! extern crate android_logger; //! extern crate android_logger;
//! //!
//! use log::LevelFilter; //! use log::Level;
//! use android_logger::{Config,FilterBuilder}; //! use android_logger::{Config,FilterBuilder};
//! //!
//! fn main() { //! fn main() {
//! android_logger::init_once( //! android_logger::init_once(
//! Config::default() //! Config::default()
//! .with_max_level(LevelFilter::Trace) //! .with_min_level(Level::Trace)
//! .with_tag("mytag") //! .with_tag("mytag")
//! .with_filter(FilterBuilder::new().parse("debug,hello::crate=trace").build()), //! .with_filter(FilterBuilder::new().parse("debug,hello::crate=trace").build()),
//! ); //! );
@ -58,7 +58,7 @@
//! //!
//! android_logger::init_once( //! android_logger::init_once(
//! Config::default() //! Config::default()
//! .with_max_level(log::LevelFilter::Trace) //! .with_min_level(log::Level::Trace)
//! .format(|f, record| write!(f, "my_app: {}", record.args())) //! .format(|f, record| write!(f, "my_app: {}", record.args()))
//! ) //! )
//! ``` //! ```
@ -72,7 +72,7 @@ extern crate log;
extern crate env_logger; extern crate env_logger;
use log::{Level, LevelFilter, Log, Metadata, Record}; use log::{Level, Log, Metadata, Record};
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
use log_ffi::LogPriority; use log_ffi::LogPriority;
use std::ffi::{CStr, CString}; use std::ffi::{CStr, CString};
@ -137,7 +137,7 @@ impl Log for AndroidLogger {
fn enabled(&self, metadata: &Metadata) -> bool { fn enabled(&self, metadata: &Metadata) -> bool {
let config = self.config(); let config = self.config();
// todo: consider __android_log_is_loggable. // todo: consider __android_log_is_loggable.
metadata.level() <= config.log_level.unwrap_or_else(log::max_level) Some(metadata.level()) >= config.log_level
} }
fn log(&self, record: &Record) { fn log(&self, record: &Record) {
@ -214,29 +214,18 @@ impl AndroidLogger {
/// Filter for android logger. /// Filter for android logger.
#[derive(Default)] #[derive(Default)]
pub struct Config { pub struct Config {
log_level: Option<LevelFilter>, log_level: Option<Level>,
filter: Option<env_logger::filter::Filter>, filter: Option<env_logger::filter::Filter>,
tag: Option<CString>, tag: Option<CString>,
custom_format: Option<FormatFn>, custom_format: Option<FormatFn>,
} }
impl Config { impl Config {
// TODO: Remove on 0.13 version release. /// Change the minimum log level.
/// **DEPRECATED**, use [`Config::with_max_level()`] instead.
#[deprecated(note = "use `.with_max_level()` instead")]
pub fn with_min_level(self, level: Level) -> Self {
self.with_max_level(level.to_level_filter())
}
/// Changes the maximum log level.
/// ///
/// Note, that `Trace` is the maximum level, because it provides the /// All values above the set level are logged. For example, if
/// maximum amount of detail in the emitted logs. /// `Warn` is set, the `Error` is logged too, but `Info` isn't.
/// pub fn with_min_level(mut self, level: Level) -> Self {
/// If `Off` level is provided, then nothing is logged at all.
///
/// [`log::max_level()`] is considered as the default level.
pub fn with_max_level(mut self, level: LevelFilter) -> Self {
self.log_level = Some(level); self.log_level = Some(level);
self self
} }
@ -264,7 +253,7 @@ impl Config {
/// # use android_logger::Config; /// # use android_logger::Config;
/// android_logger::init_once( /// android_logger::init_once(
/// Config::default() /// Config::default()
/// .with_max_level(log::LevelFilter::Trace) /// .with_min_level(log::Level::Trace)
/// .format(|f, record| write!(f, "my_app: {}", record.args())) /// .format(|f, record| write!(f, "my_app: {}", record.args()))
/// ) /// )
/// ``` /// ```
@ -460,7 +449,7 @@ pub fn init_once(config: Config) {
if let Err(err) = log::set_logger(logger) { if let Err(err) = log::set_logger(logger) {
debug!("android_logger: log::set_logger failed: {}", err); debug!("android_logger: log::set_logger failed: {}", err);
} else if let Some(level) = log_level { } else if let Some(level) = log_level {
log::set_max_level(level); log::set_max_level(level.to_level_filter());
} }
} }
@ -480,10 +469,10 @@ mod tests {
fn check_config_values() { fn check_config_values() {
// Filter is checked in config_filter_match below. // Filter is checked in config_filter_match below.
let config = Config::default() let config = Config::default()
.with_max_level(LevelFilter::Trace) .with_min_level(Level::Trace)
.with_tag("my_app"); .with_tag("my_app");
assert_eq!(config.log_level, Some(LevelFilter::Trace)); assert_eq!(config.log_level, Some(Level::Trace));
assert_eq!(config.tag, Some(CString::new("my_app").unwrap())); assert_eq!(config.tag, Some(CString::new("my_app").unwrap()));
} }
@ -491,7 +480,7 @@ mod tests {
fn log_calls_formatter() { fn log_calls_formatter() {
static FORMAT_FN_WAS_CALLED: AtomicBool = AtomicBool::new(false); static FORMAT_FN_WAS_CALLED: AtomicBool = AtomicBool::new(false);
let config = Config::default() let config = Config::default()
.with_max_level(LevelFilter::Info) .with_min_level(Level::Info)
.format(|_, _| { .format(|_, _| {
FORMAT_FN_WAS_CALLED.store(true, Ordering::SeqCst); FORMAT_FN_WAS_CALLED.store(true, Ordering::SeqCst);
Ok(()) Ok(())
@ -504,12 +493,10 @@ mod tests {
} }
#[test] #[test]
fn logger_enabled_threshold() { fn logger_always_enabled() {
let logger = AndroidLogger::new(Config::default().with_max_level(LevelFilter::Info)); let logger = AndroidLogger::new(Config::default());
assert!(logger.enabled(&log::MetadataBuilder::new().level(Level::Warn).build())); assert!(logger.enabled(&log::MetadataBuilder::new().build()));
assert!(logger.enabled(&log::MetadataBuilder::new().level(Level::Info).build()));
assert!(!logger.enabled(&log::MetadataBuilder::new().level(Level::Debug).build()));
} }
// Test whether the filter gets called correctly. Not meant to be exhaustive for all filter // Test whether the filter gets called correctly. Not meant to be exhaustive for all filter

View File

@ -3,9 +3,7 @@ extern crate log;
#[test] #[test]
fn config_log_level() { fn config_log_level() {
android_logger::init_once( android_logger::init_once(android_logger::Config::default().with_min_level(log::Level::Trace));
android_logger::Config::default().with_max_level(log::LevelFilter::Trace),
);
assert_eq!(log::max_level(), log::LevelFilter::Trace); assert_eq!(log::max_level(), log::LevelFilter::Trace);
} }

View File

@ -3,14 +3,10 @@ extern crate log;
#[test] #[test]
fn multiple_init() { fn multiple_init() {
android_logger::init_once( android_logger::init_once(android_logger::Config::default().with_min_level(log::Level::Trace));
android_logger::Config::default().with_max_level(log::LevelFilter::Trace),
);
// Second initialization should be silently ignored // Second initialization should be silently ignored
android_logger::init_once( android_logger::init_once(android_logger::Config::default().with_min_level(log::Level::Error));
android_logger::Config::default().with_max_level(log::LevelFilter::Error),
);
assert_eq!(log::max_level(), log::LevelFilter::Trace); assert_eq!(log::max_level(), log::LevelFilter::Trace);
} }

File diff suppressed because one or more lines are too long

View File

@ -13,7 +13,7 @@
edition = "2021" edition = "2021"
rust-version = "1.60" rust-version = "1.60"
name = "glean-core" name = "glean-core"
version = "52.3.0" version = "52.2.0"
authors = [ authors = [
"Jan-Erik Rediger <jrediger@mozilla.com>", "Jan-Erik Rediger <jrediger@mozilla.com>",
"The Glean Team <glean-team@mozilla.com>", "The Glean Team <glean-team@mozilla.com>",
@ -49,7 +49,7 @@ features = ["serde"]
version = "0.5" version = "0.5"
[dependencies.env_logger] [dependencies.env_logger]
version = "0.10.0" version = "0.9.0"
optional = true optional = true
default-features = false default-features = false
@ -98,9 +98,10 @@ version = "0.1.0"
version = "0.1.12" version = "0.1.12"
[dev-dependencies.env_logger] [dev-dependencies.env_logger]
version = "0.10.0" version = "0.9.0"
features = [ features = [
"auto-color", "termcolor",
"atty",
"humantime", "humantime",
] ]
default-features = false default-features = false
@ -121,7 +122,7 @@ enable_env_logger = ["env_logger"]
preinit_million_queue = [] preinit_million_queue = []
[target."cfg(target_os = \"android\")".dependencies.android_logger] [target."cfg(target_os = \"android\")".dependencies.android_logger]
version = "0.12.0" version = "0.11.0"
default-features = false default-features = false
[target."cfg(target_os = \"ios\")".dependencies.oslog] [target."cfg(target_os = \"ios\")".dependencies.oslog]

View File

@ -460,12 +460,7 @@ impl Database {
for ping_name in data.storage_names() { for ping_name in data.storage_names() {
if let Err(e) = self.record_per_lifetime(data.inner.lifetime, ping_name, &name, value) { if let Err(e) = self.record_per_lifetime(data.inner.lifetime, ping_name, &name, value) {
log::error!( log::error!("Failed to record metric into {}: {:?}", ping_name, e);
"Failed to record metric '{}' into {}: {:?}",
data.base_identifier(),
ping_name,
e
);
} }
} }
} }
@ -528,12 +523,7 @@ impl Database {
if let Err(e) = if let Err(e) =
self.record_per_lifetime_with(data.inner.lifetime, ping_name, &name, &mut transform) self.record_per_lifetime_with(data.inner.lifetime, ping_name, &name, &mut transform)
{ {
log::error!( log::error!("Failed to record metric into {}: {:?}", ping_name, e);
"Failed to record metric '{}' into {}: {:?}",
data.base_identifier(),
ping_name,
e
);
} }
} }
} }

View File

@ -5,7 +5,6 @@
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::RwLock; use std::sync::RwLock;
use std::thread;
use super::{DispatchError, DispatchGuard, Dispatcher}; use super::{DispatchError, DispatchGuard, Dispatcher};
@ -46,11 +45,6 @@ fn guard() -> DispatchGuard {
/// ///
/// [`flush_init`]: fn.flush_init.html /// [`flush_init`]: fn.flush_init.html
pub fn launch(task: impl FnOnce() + Send + 'static) { pub fn launch(task: impl FnOnce() + Send + 'static) {
let current_thread = thread::current();
if let Some("glean.shutdown") = current_thread.name() {
log::error!("Tried to launch a task from the shutdown thread. That is forbidden.");
}
let guard = guard(); let guard = guard();
match guard.launch(task) { match guard.launch(task) {
Ok(_) => {} Ok(_) => {}

View File

@ -102,7 +102,7 @@ callback interface OnGleanEvents {
// The language SDK can do additional things from within the same initializer thread, // The language SDK can do additional things from within the same initializer thread,
// e.g. starting to observe application events for foreground/background behavior. // e.g. starting to observe application events for foreground/background behavior.
// The observer then needs to call the respective client activity API. // The observer then needs to call the respective client activity API.
void initialize_finished(); void on_initialize_finished();
// Trigger the uploader whenever a ping was submitted. // Trigger the uploader whenever a ping was submitted.
// //
@ -123,15 +123,6 @@ callback interface OnGleanEvents {
// Called when upload is disabled and uploads should be stopped // Called when upload is disabled and uploads should be stopped
[Throws=CallbackError] [Throws=CallbackError]
void cancel_uploads(); void cancel_uploads();
// Called on shutdown, before Glean is fully shutdown.
//
// * This MUST NOT put any new tasks on the dispatcher.
// * New tasks will be ignored.
// * This SHOULD NOT block arbitrarily long.
// * Shutdown waits for a maximum of 30 seconds.
[Throws=CallbackError]
void shutdown();
}; };
// Deserialized experiment data. // Deserialized experiment data.

View File

@ -21,9 +21,6 @@ pub struct AdditionalMetrics {
/// A count of the pings submitted, by ping type. /// A count of the pings submitted, by ping type.
pub pings_submitted: LabeledMetric<CounterMetric>, pub pings_submitted: LabeledMetric<CounterMetric>,
/// Time waited for the uploader at shutdown.
pub shutdown_wait: TimingDistributionMetric,
} }
impl CoreMetrics { impl CoreMetrics {
@ -85,18 +82,6 @@ impl AdditionalMetrics {
}, },
None, None,
), ),
shutdown_wait: TimingDistributionMetric::new(
CommonMetricData {
name: "shutdown_wait".into(),
category: "glean.validation".into(),
send_in_pings: vec!["metrics".into()],
lifetime: Lifetime::Ping,
disabled: false,
dynamic_label: None,
},
TimeUnit::Millisecond,
),
} }
} }
} }
@ -108,10 +93,6 @@ pub struct UploadMetrics {
pub pending_pings_directory_size: MemoryDistributionMetric, pub pending_pings_directory_size: MemoryDistributionMetric,
pub deleted_pings_after_quota_hit: CounterMetric, pub deleted_pings_after_quota_hit: CounterMetric,
pub pending_pings: CounterMetric, pub pending_pings: CounterMetric,
pub send_success: TimingDistributionMetric,
pub send_failure: TimingDistributionMetric,
pub in_flight_pings_dropped: CounterMetric,
pub missing_send_ids: CounterMetric,
} }
impl UploadMetrics { impl UploadMetrics {
@ -176,48 +157,6 @@ impl UploadMetrics {
disabled: false, disabled: false,
dynamic_label: None, dynamic_label: None,
}), }),
send_success: TimingDistributionMetric::new(
CommonMetricData {
name: "send_success".into(),
category: "glean.upload".into(),
send_in_pings: vec!["metrics".into()],
lifetime: Lifetime::Ping,
disabled: false,
dynamic_label: None,
},
TimeUnit::Millisecond,
),
send_failure: TimingDistributionMetric::new(
CommonMetricData {
name: "send_failure".into(),
category: "glean.upload".into(),
send_in_pings: vec!["metrics".into()],
lifetime: Lifetime::Ping,
disabled: false,
dynamic_label: None,
},
TimeUnit::Millisecond,
),
in_flight_pings_dropped: CounterMetric::new(CommonMetricData {
name: "in_flight_pings_dropped".into(),
category: "glean.upload".into(),
send_in_pings: vec!["metrics".into()],
lifetime: Lifetime::Ping,
disabled: false,
dynamic_label: None,
}),
missing_send_ids: CounterMetric::new(CommonMetricData {
name: "missing_send_ids".into(),
category: "glean.upload".into(),
send_in_pings: vec!["metrics".into()],
lifetime: Lifetime::Ping,
disabled: false,
dynamic_label: None,
}),
} }
} }
} }

View File

@ -21,14 +21,10 @@ use std::convert::TryFrom;
use std::fmt; use std::fmt;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
use crossbeam_channel::unbounded;
use once_cell::sync::{Lazy, OnceCell};
use uuid::Uuid;
use metrics::MetricsDisabledConfig; use metrics::MetricsDisabledConfig;
use once_cell::sync::{Lazy, OnceCell};
use uuid::Uuid;
mod common_metric_data; mod common_metric_data;
mod core; mod core;
@ -228,7 +224,7 @@ pub trait OnGleanEvents: Send {
/// The language SDK can do additional things from within the same initializer thread, /// The language SDK can do additional things from within the same initializer thread,
/// e.g. starting to observe application events for foreground/background behavior. /// e.g. starting to observe application events for foreground/background behavior.
/// The observer then needs to call the respective client activity API. /// The observer then needs to call the respective client activity API.
fn initialize_finished(&self); fn on_initialize_finished(&self);
/// Trigger the uploader whenever a ping was submitted. /// Trigger the uploader whenever a ping was submitted.
/// ///
@ -241,17 +237,6 @@ pub trait OnGleanEvents: Send {
/// Called when upload is disabled and uploads should be stopped /// Called when upload is disabled and uploads should be stopped
fn cancel_uploads(&self) -> Result<(), CallbackError>; fn cancel_uploads(&self) -> Result<(), CallbackError>;
/// Called on shutdown, before glean-core is fully shutdown.
///
/// * This MUST NOT put any new tasks on the dispatcher.
/// * New tasks will be ignored.
/// * This SHOULD NOT block arbitrarily long.
/// * Shutdown waits for a maximum of 30 seconds.
fn shutdown(&self) -> Result<(), CallbackError> {
// empty by default
Ok(())
}
} }
/// Initializes Glean. /// Initializes Glean.
@ -461,7 +446,7 @@ fn initialize_inner(
} }
let state = global_state().lock().unwrap(); let state = global_state().lock().unwrap();
state.callbacks.initialize_finished(); state.callbacks.on_initialize_finished();
}) })
.expect("Failed to spawn Glean's init thread"); .expect("Failed to spawn Glean's init thread");
@ -488,54 +473,6 @@ pub fn join_init() {
} }
} }
/// Call the `shutdown` callback.
///
/// This calls the shutdown in a separate thread and waits up to 30s for it to finish.
/// If not finished in that time frame it continues.
///
/// Under normal operation that is fine, as the main process will end
/// and thus the thread will get killed.
fn uploader_shutdown() {
let timer_id = core::with_glean(|glean| glean.additional_metrics.shutdown_wait.start_sync());
let (tx, rx) = unbounded();
let handle = thread::Builder::new()
.name("glean.shutdown".to_string())
.spawn(move || {
let state = global_state().lock().unwrap();
if let Err(e) = state.callbacks.shutdown() {
log::error!("Shutdown callback failed: {e:?}");
}
// Best-effort sending. The other side might have timed out already.
let _ = tx.send(()).ok();
})
.expect("Unable to spawn thread to wait on shutdown");
// TODO: 30 seconds? What's a good default here? Should this be configurable?
// Reasoning:
// * If we shut down early we might still be processing pending pings.
// In this case we wait at most 3 times for 1s = 3s before we upload.
// * If we're rate-limited the uploader sleeps for up to 60s.
// Thus waiting 30s will rarely allow another upload.
// * We don't know how long uploads take until we get data from bug 1814592.
let result = rx.recv_timeout(Duration::from_secs(30));
let stop_time = time::precise_time_ns();
core::with_glean(|glean| {
glean
.additional_metrics
.shutdown_wait
.set_stop_and_accumulate(glean, timer_id, stop_time);
});
if result.is_err() {
log::warn!("Waiting for upload failed. We're shutting down.");
} else {
let _ = handle.join().ok();
}
}
/// Shuts down Glean in an orderly fashion. /// Shuts down Glean in an orderly fashion.
pub fn shutdown() { pub fn shutdown() {
// Either init was never called or Glean was not fully initialized // Either init was never called or Glean was not fully initialized
@ -563,8 +500,6 @@ pub fn shutdown() {
log::error!("Can't shutdown dispatcher thread: {:?}", e); log::error!("Can't shutdown dispatcher thread: {:?}", e);
} }
uploader_shutdown();
// Be sure to call this _after_ draining the dispatcher // Be sure to call this _after_ draining the dispatcher
core::with_glean(|glean| { core::with_glean(|glean| {
if let Err(e) = glean.persist_ping_lifetime_data() { if let Err(e) = glean.persist_ping_lifetime_data() {
@ -638,7 +573,7 @@ pub extern "C" fn glean_enable_logging() {
.build(); .build();
android_logger::init_once( android_logger::init_once(
android_logger::Config::default() android_logger::Config::default()
.with_max_level(log::LevelFilter::Debug) .with_min_level(log::Level::Debug)
.with_filter(filter) .with_filter(filter)
.with_tag("libglean_ffi"), .with_tag("libglean_ffi"),
); );
@ -960,14 +895,6 @@ pub fn glean_test_destroy_glean(clear_stores: bool, data_path: Option<String>) {
dispatcher::reset_dispatcher(); dispatcher::reset_dispatcher();
// Only useful if Glean initialization finished successfully
// and set up the storage.
let has_storage =
core::with_opt_glean(|glean| glean.storage_opt().is_some()).unwrap_or(false);
if has_storage {
uploader_shutdown();
}
if core::global_glean().is_some() { if core::global_glean().is_some() {
core::with_glean_mut(|glean| { core::with_glean_mut(|glean| {
if clear_stores { if clear_stores {

View File

@ -27,7 +27,7 @@ pub fn new_glean(tempdir: Option<tempfile::TempDir>) -> (Glean, tempfile::TempDi
#[test] #[test]
fn path_is_constructed_from_data() { fn path_is_constructed_from_data() {
let (glean, _t) = new_glean(None); let (glean, _) = new_glean(None);
assert_eq!( assert_eq!(
"/submit/org-mozilla-glean-test-app/baseline/1/this-is-a-docid", "/submit/org-mozilla-glean-test-app/baseline/1/this-is-a-docid",
@ -241,7 +241,7 @@ fn basic_metrics_should_be_cleared_when_uploading_is_disabled() {
#[test] #[test]
fn first_run_date_is_managed_correctly_when_toggling_uploading() { fn first_run_date_is_managed_correctly_when_toggling_uploading() {
let (mut glean, _t) = new_glean(None); let (mut glean, _) = new_glean(None);
let original_first_run_date = glean let original_first_run_date = glean
.core_metrics .core_metrics
@ -269,7 +269,7 @@ fn first_run_date_is_managed_correctly_when_toggling_uploading() {
#[test] #[test]
fn client_id_is_managed_correctly_when_toggling_uploading() { fn client_id_is_managed_correctly_when_toggling_uploading() {
let (mut glean, _t) = new_glean(None); let (mut glean, _) = new_glean(None);
let original_client_id = glean let original_client_id = glean
.core_metrics .core_metrics
@ -611,7 +611,7 @@ fn test_dirty_bit() {
fn test_change_metric_type_runtime() { fn test_change_metric_type_runtime() {
let dir = tempfile::tempdir().unwrap(); let dir = tempfile::tempdir().unwrap();
let (glean, _t) = new_glean(Some(dir)); let (glean, _) = new_glean(Some(dir));
// We attempt to create two metrics: one with a 'string' type and the other // We attempt to create two metrics: one with a 'string' type and the other
// with a 'timespan' type, both being sent in the same pings and having the // with a 'timespan' type, both being sent in the same pings and having the
@ -670,7 +670,7 @@ fn test_change_metric_type_runtime() {
fn timing_distribution_truncation() { fn timing_distribution_truncation() {
let dir = tempfile::tempdir().unwrap(); let dir = tempfile::tempdir().unwrap();
let (glean, _t) = new_glean(Some(dir)); let (glean, _) = new_glean(Some(dir));
let max_sample_time = 1000 * 1000 * 1000 * 60 * 10; let max_sample_time = 1000 * 1000 * 1000 * 60 * 10;
for (unit, expected_keys) in &[ for (unit, expected_keys) in &[
@ -744,7 +744,7 @@ fn timing_distribution_truncation() {
fn timing_distribution_truncation_accumulate() { fn timing_distribution_truncation_accumulate() {
let dir = tempfile::tempdir().unwrap(); let dir = tempfile::tempdir().unwrap();
let (glean, _t) = new_glean(Some(dir)); let (glean, _) = new_glean(Some(dir));
let max_sample_time = 1000 * 1000 * 1000 * 60 * 10; let max_sample_time = 1000 * 1000 * 1000 * 60 * 10;
for &unit in &[ for &unit in &[
@ -790,7 +790,7 @@ fn timing_distribution_truncation_accumulate() {
fn test_setting_debug_view_tag() { fn test_setting_debug_view_tag() {
let dir = tempfile::tempdir().unwrap(); let dir = tempfile::tempdir().unwrap();
let (mut glean, _t) = new_glean(Some(dir)); let (mut glean, _) = new_glean(Some(dir));
let valid_tag = "valid-tag"; let valid_tag = "valid-tag";
assert!(glean.set_debug_view_tag(valid_tag)); assert!(glean.set_debug_view_tag(valid_tag));
@ -805,7 +805,7 @@ fn test_setting_debug_view_tag() {
fn test_setting_log_pings() { fn test_setting_log_pings() {
let dir = tempfile::tempdir().unwrap(); let dir = tempfile::tempdir().unwrap();
let (mut glean, _t) = new_glean(Some(dir)); let (mut glean, _) = new_glean(Some(dir));
assert!(!glean.log_pings()); assert!(!glean.log_pings());
glean.set_log_pings(true); glean.set_log_pings(true);
@ -1064,7 +1064,7 @@ fn test_activity_api() {
let _ = env_logger::builder().is_test(true).try_init(); let _ = env_logger::builder().is_test(true).try_init();
let dir = tempfile::tempdir().unwrap(); let dir = tempfile::tempdir().unwrap();
let (mut glean, _t) = new_glean(Some(dir)); let (mut glean, _) = new_glean(Some(dir));
// Signal that the client was active. // Signal that the client was active.
glean.handle_client_active(); glean.handle_client_active();

View File

@ -13,7 +13,7 @@ use crate::Glean;
const MAX_LABELS: usize = 16; const MAX_LABELS: usize = 16;
const OTHER_LABEL: &str = "__other__"; const OTHER_LABEL: &str = "__other__";
const MAX_LABEL_LENGTH: usize = 71; const MAX_LABEL_LENGTH: usize = 61;
/// A labeled counter. /// A labeled counter.
pub type LabeledCounter = LabeledMetric<CounterMetric>; pub type LabeledCounter = LabeledMetric<CounterMetric>;
@ -24,6 +24,66 @@ pub type LabeledBoolean = LabeledMetric<BooleanMetric>;
/// A labeled string. /// A labeled string.
pub type LabeledString = LabeledMetric<StringMetric>; pub type LabeledString = LabeledMetric<StringMetric>;
/// Checks whether the given label is sane.
///
/// The check corresponds to the following regular expression:
///
/// ```text
/// ^[a-z_][a-z0-9_-]{0,29}(\\.[a-z_][a-z0-9_-]{0,29})*$
/// ```
///
/// We do a manul check here instead of using a regex,
/// because the regex crate adds to the binary size significantly,
/// and the Glean SDK doesn't use regular expressions anywhere else.
///
/// Some examples of good and bad labels:
///
/// Good:
/// * `this.is.fine`
/// * `this_is_fine_too`
/// * `this.is_still_fine`
/// * `thisisfine`
/// * `_.is_fine`
/// * `this.is-fine`
/// * `this-is-fine`
/// Bad:
/// * `this.is.not_fine_due_tu_the_length_being_too_long_i_thing.i.guess`
/// * `1.not_fine`
/// * `this.$isnotfine`
/// * `-.not_fine`
fn matches_label_regex(value: &str) -> bool {
let mut iter = value.chars();
loop {
// Match the first letter in the word.
match iter.next() {
Some('_') | Some('a'..='z') => (),
_ => return false,
};
// Match subsequent letters in the word.
let mut count = 0;
loop {
match iter.next() {
// We are done, so the whole expression is valid.
None => return true,
// Valid characters.
Some('_') | Some('-') | Some('a'..='z') | Some('0'..='9') => (),
// We ended a word, so iterate over the outer loop again.
Some('.') => break,
// An invalid character
_ => return false,
}
count += 1;
// We allow 30 characters per word, but the first one is handled
// above outside of this loop, so we have a maximum of 29 here.
if count == 29 {
return false;
}
}
}
}
/// A labeled metric. /// A labeled metric.
/// ///
/// Labeled metrics allow to record multiple sub-metrics of the same type under different string labels. /// Labeled metrics allow to record multiple sub-metrics of the same type under different string labels.
@ -278,8 +338,8 @@ pub fn validate_dynamic_label(
); );
record_error(glean, meta, ErrorType::InvalidLabel, msg, None); record_error(glean, meta, ErrorType::InvalidLabel, msg, None);
true true
} else if label.chars().any(|c| !c.is_ascii() || c.is_ascii_control()) { } else if !matches_label_regex(label) {
let msg = format!("label must be printable ascii, got '{}'", label); let msg = format!("label must be snake_case, got '{}'", label);
record_error(glean, meta, ErrorType::InvalidLabel, msg, None); record_error(glean, meta, ErrorType::InvalidLabel, msg, None);
true true
} else { } else {

View File

@ -150,7 +150,7 @@ mod test {
#[test] #[test]
fn setting_a_long_string_records_an_error() { fn setting_a_long_string_records_an_error() {
let (glean, _t) = new_glean(None); let (glean, _) = new_glean(None);
let metric = StringMetric::new(CommonMetricData { let metric = StringMetric::new(CommonMetricData {
name: "string_metric".into(), name: "string_metric".into(),

View File

@ -154,7 +154,7 @@ mod test {
#[test] #[test]
fn setting_a_long_string_records_an_error() { fn setting_a_long_string_records_an_error() {
let (glean, _t) = new_glean(None); let (glean, _) = new_glean(None);
let metric = TextMetric::new(CommonMetricData { let metric = TextMetric::new(CommonMetricData {
name: "text_metric".into(), name: "text_metric".into(),

View File

@ -123,14 +123,6 @@ impl TimingDistributionMetric {
id id
} }
pub(crate) fn start_sync(&self) -> TimerId {
let start_time = time::precise_time_ns();
let id = self.next_id.fetch_add(1, Ordering::SeqCst).into();
let metric = self.clone();
metric.set_start(id, start_time);
id
}
/// **Test-only API (exported for testing purposes).** /// **Test-only API (exported for testing purposes).**
/// ///
/// Set start time for this metric synchronously. /// Set start time for this metric synchronously.
@ -224,14 +216,9 @@ impl TimingDistributionMetric {
return; return;
} }
// Let's be defensive here: glean
// The uploader tries to store some timing distribution metrics, .storage()
// but in tests that storage might be gone already. .record_with(glean, &self.meta, |old_value| match old_value {
// Let's just ignore those.
// We do the same for counters.
// This should never happen in real app usage.
if let Some(storage) = glean.storage_opt() {
storage.record_with(glean, &self.meta, |old_value| match old_value {
Some(Metric::TimingDistribution(mut hist)) => { Some(Metric::TimingDistribution(mut hist)) => {
hist.accumulate(duration); hist.accumulate(duration);
Metric::TimingDistribution(hist) Metric::TimingDistribution(hist)
@ -242,12 +229,6 @@ impl TimingDistributionMetric {
Metric::TimingDistribution(hist) Metric::TimingDistribution(hist)
} }
}); });
} else {
log::warn!(
"Couldn't get storage. Can't record timing distribution '{}'.",
self.meta.base_identifier()
);
}
} }
/// Aborts a previous [`start`](Self::start) call. /// Aborts a previous [`start`](Self::start) call.
@ -265,7 +246,7 @@ impl TimingDistributionMetric {
} }
/// Aborts a previous [`start`](Self::start) call synchronously. /// Aborts a previous [`start`](Self::start) call synchronously.
pub(crate) fn cancel_sync(&self, id: TimerId) { fn cancel_sync(&self, id: TimerId) {
let mut map = self.start_times.lock().expect("can't lock timings map"); let mut map = self.start_times.lock().expect("can't lock timings map");
map.remove(&id); map.remove(&id);
} }

View File

@ -168,7 +168,7 @@ mod test {
#[test] #[test]
fn payload_is_correct() { fn payload_is_correct() {
let (glean, _t) = new_glean(None); let (glean, _) = new_glean(None);
let metric = UrlMetric::new(CommonMetricData { let metric = UrlMetric::new(CommonMetricData {
name: "url_metric".into(), name: "url_metric".into(),
@ -186,7 +186,7 @@ mod test {
#[test] #[test]
fn does_not_record_url_exceeding_maximum_length() { fn does_not_record_url_exceeding_maximum_length() {
let (glean, _t) = new_glean(None); let (glean, _) = new_glean(None);
let metric = UrlMetric::new(CommonMetricData { let metric = UrlMetric::new(CommonMetricData {
name: "url_metric".into(), name: "url_metric".into(),
@ -224,7 +224,7 @@ mod test {
#[test] #[test]
fn does_not_record_data_urls() { fn does_not_record_data_urls() {
let (glean, _t) = new_glean(None); let (glean, _) = new_glean(None);
let metric = UrlMetric::new(CommonMetricData { let metric = UrlMetric::new(CommonMetricData {
name: "url_metric".into(), name: "url_metric".into(),
@ -248,7 +248,7 @@ mod test {
#[test] #[test]
fn url_validation_works_and_records_errors() { fn url_validation_works_and_records_errors() {
let (glean, _t) = new_glean(None); let (glean, _) = new_glean(None);
let metric = UrlMetric::new(CommonMetricData { let metric = UrlMetric::new(CommonMetricData {
name: "url_metric".into(), name: "url_metric".into(),

View File

@ -374,7 +374,7 @@ mod test {
#[test] #[test]
fn sequence_numbers_should_be_reset_when_toggling_uploading() { fn sequence_numbers_should_be_reset_when_toggling_uploading() {
let (mut glean, _t) = new_glean(None); let (mut glean, _) = new_glean(None);
let ping_maker = PingMaker::new(); let ping_maker = PingMaker::new();
assert_eq!(0, ping_maker.get_ping_seq(&glean, "custom")); assert_eq!(0, ping_maker.get_ping_seq(&glean, "custom"));

View File

@ -12,7 +12,6 @@
//! API to check the HTTP response from the ping upload and either delete the //! API to check the HTTP response from the ping upload and either delete the
//! corresponding ping from disk or re-enqueue it for sending. //! corresponding ping from disk or re-enqueue it for sending.
use std::collections::HashMap;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::convert::TryInto; use std::convert::TryInto;
use std::path::PathBuf; use std::path::PathBuf;
@ -22,7 +21,6 @@ use std::thread;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use crate::error::ErrorKind; use crate::error::ErrorKind;
use crate::TimerId;
use crate::{internal_metrics::UploadMetrics, Glean}; use crate::{internal_metrics::UploadMetrics, Glean};
use directory::{PingDirectoryManager, PingPayloadsByDirectory}; use directory::{PingDirectoryManager, PingPayloadsByDirectory};
use policy::Policy; use policy::Policy;
@ -207,8 +205,6 @@ pub struct PingUploadManager {
upload_metrics: UploadMetrics, upload_metrics: UploadMetrics,
/// Policies for ping storage, uploading and requests. /// Policies for ping storage, uploading and requests.
policy: Policy, policy: Policy,
in_flight: RwLock<HashMap<String, (TimerId, TimerId)>>,
} }
impl PingUploadManager { impl PingUploadManager {
@ -234,7 +230,6 @@ impl PingUploadManager {
language_binding_name: language_binding_name.into(), language_binding_name: language_binding_name.into(),
upload_metrics: UploadMetrics::new(), upload_metrics: UploadMetrics::new(),
policy: Policy::default(), policy: Policy::default(),
in_flight: RwLock::new(HashMap::default()),
} }
} }
@ -365,21 +360,6 @@ impl PingUploadManager {
return; return;
} }
{
let in_flight = self.in_flight.read().unwrap();
if in_flight.contains_key(document_id) {
log::warn!(
"Attempted to enqueue an in-flight ping {} at {}.",
document_id,
path
);
self.upload_metrics
.in_flight_pings_dropped
.add_sync(glean, 0);
return;
}
}
log::trace!("Enqueuing ping {} at {}", document_id, path); log::trace!("Enqueuing ping {} at {}", document_id, path);
if let Some(request) = self.build_ping_request(glean, document_id, path, body, headers) { if let Some(request) = self.build_ping_request(glean, document_id, path, body, headers) {
queue.push_back(request) queue.push_back(request)
@ -595,16 +575,6 @@ impl PingUploadManager {
} }
} }
{
// Synchronous timer starts.
// We're in the uploader thread anyway.
// But also: No data is stored on disk.
let mut in_flight = self.in_flight.write().unwrap();
let success_id = self.upload_metrics.send_success.start_sync();
let failure_id = self.upload_metrics.send_failure.start_sync();
in_flight.insert(request.document_id.clone(), (success_id, failure_id));
}
PingUploadTask::Upload { PingUploadTask::Upload {
request: queue.pop_front().unwrap(), request: queue.pop_front().unwrap(),
} }
@ -686,31 +656,14 @@ impl PingUploadManager {
) -> UploadTaskAction { ) -> UploadTaskAction {
use UploadResult::*; use UploadResult::*;
let stop_time = time::precise_time_ns();
if let Some(label) = status.get_label() { if let Some(label) = status.get_label() {
let metric = self.upload_metrics.ping_upload_failure.get(label); let metric = self.upload_metrics.ping_upload_failure.get(label);
metric.add_sync(glean, 1); metric.add_sync(glean, 1);
} }
let send_ids = {
let mut lock = self.in_flight.write().unwrap();
lock.remove(document_id)
};
if send_ids.is_none() {
self.upload_metrics.missing_send_ids.add_sync(glean, 1);
}
match status { match status {
HttpStatus { code } if (200..=299).contains(&code) => { HttpStatus { code } if (200..=299).contains(&code) => {
log::info!("Ping {} successfully sent {}.", document_id, code); log::info!("Ping {} successfully sent {}.", document_id, code);
if let Some((success_id, failure_id)) = send_ids {
self.upload_metrics
.send_success
.set_stop_and_accumulate(glean, success_id, stop_time);
self.upload_metrics.send_failure.cancel_sync(failure_id);
}
self.directory_manager.delete_file(document_id); self.directory_manager.delete_file(document_id);
} }
@ -720,12 +673,6 @@ impl PingUploadManager {
document_id, document_id,
status status
); );
if let Some((success_id, failure_id)) = send_ids {
self.upload_metrics.send_success.cancel_sync(success_id);
self.upload_metrics
.send_failure
.set_stop_and_accumulate(glean, failure_id, stop_time);
}
self.directory_manager.delete_file(document_id); self.directory_manager.delete_file(document_id);
} }
@ -735,12 +682,6 @@ impl PingUploadManager {
document_id, document_id,
status status
); );
if let Some((success_id, failure_id)) = send_ids {
self.upload_metrics.send_success.cancel_sync(success_id);
self.upload_metrics
.send_failure
.set_stop_and_accumulate(glean, failure_id, stop_time);
}
self.enqueue_ping_from_file(glean, document_id); self.enqueue_ping_from_file(glean, document_id);
self.recoverable_failure_count self.recoverable_failure_count
.fetch_add(1, Ordering::SeqCst); .fetch_add(1, Ordering::SeqCst);
@ -748,10 +689,6 @@ impl PingUploadManager {
Done { .. } => { Done { .. } => {
log::debug!("Uploader signaled Done. Exiting."); log::debug!("Uploader signaled Done. Exiting.");
if let Some((success_id, failure_id)) = send_ids {
self.upload_metrics.send_success.cancel_sync(success_id);
self.upload_metrics.send_failure.cancel_sync(failure_id);
}
return UploadTaskAction::End; return UploadTaskAction::End;
} }
}; };
@ -841,7 +778,7 @@ mod test {
#[test] #[test]
fn doesnt_error_when_there_are_no_pending_pings() { fn doesnt_error_when_there_are_no_pending_pings() {
let (glean, _t) = new_glean(None); let (glean, _) = new_glean(None);
// Try and get the next request. // Try and get the next request.
// Verify request was not returned // Verify request was not returned
@ -948,7 +885,7 @@ mod test {
#[test] #[test]
fn clearing_the_queue_doesnt_clear_deletion_request_pings() { fn clearing_the_queue_doesnt_clear_deletion_request_pings() {
let (mut glean, _t) = new_glean(None); let (mut glean, _) = new_glean(None);
// Register a ping for testing // Register a ping for testing
let ping_type = PingType::new("test", true, /* send_if_empty */ true, vec![]); let ping_type = PingType::new("test", true, /* send_if_empty */ true, vec![]);
@ -1070,7 +1007,7 @@ mod test {
#[test] #[test]
fn processes_correctly_server_error_upload_response() { fn processes_correctly_server_error_upload_response() {
let (mut glean, _t) = new_glean(None); let (mut glean, _) = new_glean(None);
// Register a ping for testing // Register a ping for testing
let ping_type = PingType::new("test", true, /* send_if_empty */ true, vec![]); let ping_type = PingType::new("test", true, /* send_if_empty */ true, vec![]);
@ -1188,7 +1125,7 @@ mod test {
#[test] #[test]
fn adds_debug_view_header_to_requests_when_tag_is_set() { fn adds_debug_view_header_to_requests_when_tag_is_set() {
let (mut glean, _t) = new_glean(None); let (mut glean, _) = new_glean(None);
glean.set_debug_view_tag("valid-tag"); glean.set_debug_view_tag("valid-tag");
@ -1643,32 +1580,4 @@ mod test {
_ => panic!("Expected upload manager to return a wait task!"), _ => panic!("Expected upload manager to return a wait task!"),
}; };
} }
#[test]
fn cannot_enqueue_ping_while_its_being_processed() {
let (glean, dir) = new_glean(None);
let upload_manager = PingUploadManager::no_policy(dir.path());
// Enqueue a ping and start processing it
let identifier = &Uuid::new_v4().to_string();
upload_manager.enqueue_ping(&glean, identifier, PATH, "", None);
assert!(upload_manager.get_upload_task(&glean, false).is_upload());
// Attempt to re-enqueue the same ping
upload_manager.enqueue_ping(&glean, identifier, PATH, "", None);
// No new pings should have been enqueued so the upload task is Done.
assert_eq!(
upload_manager.get_upload_task(&glean, false),
PingUploadTask::done()
);
// Process the upload response
upload_manager.process_ping_upload_response(
&glean,
identifier,
UploadResult::http_status(200),
);
}
} }

View File

@ -52,7 +52,7 @@ mod linear {
// Make a new Glean instance here, which should force reloading of the data from disk // Make a new Glean instance here, which should force reloading of the data from disk
// so we can ensure it persisted, because it has User lifetime // so we can ensure it persisted, because it has User lifetime
{ {
let (glean, _t) = new_glean(Some(tempdir)); let (glean, _) = new_glean(Some(tempdir));
let snapshot = StorageManager let snapshot = StorageManager
.snapshot_as_json(glean.storage(), "store1", true) .snapshot_as_json(glean.storage(), "store1", true)
.unwrap(); .unwrap();
@ -254,7 +254,7 @@ mod exponential {
// Make a new Glean instance here, which should force reloading of the data from disk // Make a new Glean instance here, which should force reloading of the data from disk
// so we can ensure it persisted, because it has User lifetime // so we can ensure it persisted, because it has User lifetime
{ {
let (glean, _t) = new_glean(Some(tempdir)); let (glean, _) = new_glean(Some(tempdir));
let snapshot = StorageManager let snapshot = StorageManager
.snapshot_as_json(glean.storage(), "store1", true) .snapshot_as_json(glean.storage(), "store1", true)
.unwrap(); .unwrap();

View File

@ -56,7 +56,7 @@ fn datetime_serializer_should_correctly_serialize_datetime() {
// Make a new Glean instance here, which should force reloading of the data from disk // Make a new Glean instance here, which should force reloading of the data from disk
// so we can ensure it persisted, because it has User lifetime // so we can ensure it persisted, because it has User lifetime
{ {
let (glean, _t) = new_glean(Some(tempdir)); let (glean, _) = new_glean(Some(tempdir));
let snapshot = StorageManager let snapshot = StorageManager
.snapshot_as_json(glean.storage(), "store1", true) .snapshot_as_json(glean.storage(), "store1", true)
.unwrap(); .unwrap();

View File

@ -231,7 +231,7 @@ fn dynamic_labels_too_long() {
None, None,
); );
let metric = labeled.get("1".repeat(72)); let metric = labeled.get("this_string_has_more_than_thirty_characters");
metric.add_sync(&glean, 1); metric.add_sync(&glean, 1);
let snapshot = StorageManager let snapshot = StorageManager
@ -266,7 +266,15 @@ fn dynamic_labels_regex_mismatch() {
None, None,
); );
let labels_not_validating = vec!["non-ASCII<49>"]; let labels_not_validating = vec![
"notSnakeCase",
"",
"with/slash",
"1.not_fine",
"this.$isnotfine",
"-.not_fine",
"this.is_not_fine.2",
];
let num_non_validating = labels_not_validating.len(); let num_non_validating = labels_not_validating.len();
for label in &labels_not_validating { for label in &labels_not_validating {
@ -386,7 +394,7 @@ fn seen_labels_get_reloaded_from_disk() {
// Force a reload // Force a reload
{ {
let (glean, _t) = new_glean(Some(tempdir)); let (glean, _) = new_glean(Some(tempdir));
// Try to store another label // Try to store another label
labeled.get("new_label").add_sync(&glean, 40); labeled.get("new_label").add_sync(&glean, 40);

View File

@ -49,7 +49,7 @@ fn serializer_should_correctly_serialize_memory_distribution() {
// Make a new Glean instance here, which should force reloading of the data from disk // Make a new Glean instance here, which should force reloading of the data from disk
// so we can ensure it persisted, because it has User lifetime // so we can ensure it persisted, because it has User lifetime
{ {
let (glean, _t) = new_glean(Some(tempdir)); let (glean, _) = new_glean(Some(tempdir));
let snapshot = StorageManager let snapshot = StorageManager
.snapshot_as_json(glean.storage(), "store1", true) .snapshot_as_json(glean.storage(), "store1", true)
.unwrap(); .unwrap();

View File

@ -34,7 +34,7 @@ fn write_ping_to_disk() {
#[test] #[test]
fn disabling_upload_clears_pending_pings() { fn disabling_upload_clears_pending_pings() {
let (mut glean, _t) = new_glean(None); let (mut glean, _) = new_glean(None);
let ping = PingType::new("metrics", true, false, vec![]); let ping = PingType::new("metrics", true, false, vec![]);
glean.register_ping_type(&ping); glean.register_ping_type(&ping);
@ -77,7 +77,7 @@ fn disabling_upload_clears_pending_pings() {
#[test] #[test]
fn deletion_request_only_when_toggled_from_on_to_off() { fn deletion_request_only_when_toggled_from_on_to_off() {
let (mut glean, _t) = new_glean(None); let (mut glean, _) = new_glean(None);
// Disabling upload generates a deletion ping // Disabling upload generates a deletion ping
glean.set_upload_enabled(false); glean.set_upload_enabled(false);
@ -103,7 +103,7 @@ fn deletion_request_only_when_toggled_from_on_to_off() {
#[test] #[test]
fn empty_pings_with_flag_are_sent() { fn empty_pings_with_flag_are_sent() {
let (mut glean, _t) = new_glean(None); let (mut glean, _) = new_glean(None);
let ping1 = PingType::new("custom-ping1", true, true, vec![]); let ping1 = PingType::new("custom-ping1", true, true, vec![]);
glean.register_ping_type(&ping1); glean.register_ping_type(&ping1);
@ -216,7 +216,7 @@ fn test_pings_submitted_metric() {
#[test] #[test]
fn events_ping_with_metric_but_no_events_is_not_sent() { fn events_ping_with_metric_but_no_events_is_not_sent() {
let (mut glean, _t) = new_glean(None); let (mut glean, _) = new_glean(None);
let events_ping = PingType::new("events", true, true, vec![]); let events_ping = PingType::new("events", true, true, vec![]);
glean.register_ping_type(&events_ping); glean.register_ping_type(&events_ping);

View File

@ -161,7 +161,7 @@ fn seq_number_must_be_sequential() {
#[test] #[test]
fn clear_pending_pings() { fn clear_pending_pings() {
let (mut glean, _t) = new_glean(None); let (mut glean, _) = new_glean(None);
let ping_maker = PingMaker::new(); let ping_maker = PingMaker::new();
let ping_type = PingType::new("store1", true, false, vec![]); let ping_type = PingType::new("store1", true, false, vec![]);
glean.register_ping_type(&ping_type); glean.register_ping_type(&ping_type);
@ -190,7 +190,7 @@ fn clear_pending_pings() {
fn no_pings_submitted_if_upload_disabled() { fn no_pings_submitted_if_upload_disabled() {
// Regression test, bug 1603571 // Regression test, bug 1603571
let (mut glean, _t) = new_glean(None); let (mut glean, _) = new_glean(None);
let ping_type = PingType::new("store1", true, true, vec![]); let ping_type = PingType::new("store1", true, true, vec![]);
glean.register_ping_type(&ping_type); glean.register_ping_type(&ping_type);
@ -207,7 +207,7 @@ fn no_pings_submitted_if_upload_disabled() {
#[test] #[test]
fn metadata_is_correctly_added_when_necessary() { fn metadata_is_correctly_added_when_necessary() {
let (mut glean, _t) = new_glean(None); let (mut glean, _) = new_glean(None);
glean.set_debug_view_tag("valid-tag"); glean.set_debug_view_tag("valid-tag");
let ping_type = PingType::new("store1", true, true, vec![]); let ping_type = PingType::new("store1", true, true, vec![]);
glean.register_ping_type(&ping_type); glean.register_ping_type(&ping_type);

View File

@ -50,7 +50,7 @@ fn quantity_serializer_should_correctly_serialize_quantities() {
// Make a new Glean instance here, which should force reloading of the data from disk // Make a new Glean instance here, which should force reloading of the data from disk
// so we can ensure it persisted, because it has User lifetime // so we can ensure it persisted, because it has User lifetime
{ {
let (glean, _t) = new_glean(Some(tempdir)); let (glean, _) = new_glean(Some(tempdir));
let snapshot = StorageManager let snapshot = StorageManager
.snapshot_as_json(glean.storage(), "store1", true) .snapshot_as_json(glean.storage(), "store1", true)
.unwrap(); .unwrap();

View File

@ -48,7 +48,7 @@ fn string_serializer_should_correctly_serialize_strings() {
// Make a new Glean instance here, which should force reloading of the data from disk // Make a new Glean instance here, which should force reloading of the data from disk
// so we can ensure it persisted, because it has User lifetime // so we can ensure it persisted, because it has User lifetime
{ {
let (glean, _t) = new_glean(Some(tempdir)); let (glean, _) = new_glean(Some(tempdir));
let snapshot = StorageManager let snapshot = StorageManager
.snapshot_as_json(glean.storage(), "store1", true) .snapshot_as_json(glean.storage(), "store1", true)
.unwrap(); .unwrap();

View File

@ -63,7 +63,7 @@ fn stringlist_serializer_should_correctly_serialize_stringlists() {
} }
{ {
let (glean, _t) = new_glean(Some(tempdir)); let (glean, _) = new_glean(Some(tempdir));
let snapshot = StorageManager let snapshot = StorageManager
.snapshot_as_json(glean.storage(), "store1", true) .snapshot_as_json(glean.storage(), "store1", true)

View File

@ -45,7 +45,7 @@ fn text_serializer_should_correctly_serialize_strings() {
// Make a new Glean instance here, which should force reloading of the data from disk // Make a new Glean instance here, which should force reloading of the data from disk
// so we can ensure it persisted, because it has User lifetime // so we can ensure it persisted, because it has User lifetime
{ {
let (glean, _t) = new_glean(Some(tempdir)); let (glean, _) = new_glean(Some(tempdir));
let snapshot = StorageManager let snapshot = StorageManager
.snapshot_as_json(glean.storage(), "store1", true) .snapshot_as_json(glean.storage(), "store1", true)
.unwrap(); .unwrap();

View File

@ -52,7 +52,7 @@ fn serializer_should_correctly_serialize_timespans() {
// Make a new Glean instance here, which should force reloading of the data from disk // Make a new Glean instance here, which should force reloading of the data from disk
// so we can ensure it persisted, because it has User lifetime // so we can ensure it persisted, because it has User lifetime
{ {
let (glean, _t) = new_glean(Some(tempdir)); let (glean, _) = new_glean(Some(tempdir));
let snapshot = StorageManager let snapshot = StorageManager
.snapshot_as_json(glean.storage(), "store1", true) .snapshot_as_json(glean.storage(), "store1", true)
.unwrap(); .unwrap();

View File

@ -54,7 +54,7 @@ fn serializer_should_correctly_serialize_timing_distribution() {
// Make a new Glean instance here, which should force reloading of the data from disk // Make a new Glean instance here, which should force reloading of the data from disk
// so we can ensure it persisted, because it has User lifetime // so we can ensure it persisted, because it has User lifetime
{ {
let (glean, _t) = new_glean(Some(tempdir)); let (glean, _) = new_glean(Some(tempdir));
let snapshot = StorageManager let snapshot = StorageManager
.snapshot_as_json(glean.storage(), "store1", true) .snapshot_as_json(glean.storage(), "store1", true)
.unwrap(); .unwrap();

View File

@ -72,7 +72,7 @@ fn uuid_serializer_should_correctly_serialize_uuids() {
// Make a new Glean instance here, which should force reloading of the data from disk // Make a new Glean instance here, which should force reloading of the data from disk
// so we can ensure it persisted, because it has User lifetime // so we can ensure it persisted, because it has User lifetime
{ {
let (glean, _t) = new_glean(Some(tempdir)); let (glean, _) = new_glean(Some(tempdir));
let snapshot = StorageManager let snapshot = StorageManager
.snapshot_as_json(glean.storage(), "store1", true) .snapshot_as_json(glean.storage(), "store1", true)
.unwrap(); .unwrap();

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"0ec3bb60b6512567be647f2ba367bda935a68abf4fedcf0dc6d38f8bc43ddb3f","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5627cc81e6187ab6c2b4dff061af16d559edcab64ba786bac39daa69c703c595","src/common_test.rs":"de47b53dcca37985c0a2b8c02daecbf32309aa54f5a4dd9290719c2c1fd0fa55","src/configuration.rs":"4ca9be0a49a9c50f4ebe868d4bfa04fe27619c871a436911f850b4dcf6e7a7b2","src/core_metrics.rs":"dd17b482613894af08b51a2cff6dc1e84a6dbd853c14a55566e6698348941ced","src/lib.rs":"2eb1b09f2f8a649729cd27222f0889eed7b50940fc7e2bb27de54abbdac439df","src/net/http_uploader.rs":"43812a70d19a38e8d7a093c8076c2b6345372c3c861b0f3511428762700a65e0","src/net/mod.rs":"e36e170a8e53530f8705988eea694ed7c55f50bb0ce403c0facbfb75ce03ac7f","src/private/event.rs":"02bbebf545695812e5055741cc0b5f3c99eda2039e684e26fcdd5f087ed15fe3","src/private/mod.rs":"0364ecf5f0439443a5b209583f4ff2c474b79f7c253c981ab0b7cdc528368698","src/private/ping.rs":"cbdc57f41fc9d46e56b4dfff91ac683753d1f8b3ecd0aa9bc3419e3595b8b81b","src/system.rs":"6eae5b41c15eba9cad6dbd116abe3519ee3e1fe034e79bdd692b029829a8c384","src/test.rs":"d367c85a106df58272b8a779da1769664ba8a39357fd650d9f21c21855b38906","tests/common/mod.rs":"37cd4c48e140c793b852ae09fb3e812da28a4412977295015bcbffd632fcf294","tests/init_fails.rs":"28fd7726e76ca1295eb0905eca0b2ec65b0accfa28432c9ff90ec8f92616fc79","tests/never_init.rs":"1f33b8ce7ca3514b57b48cc16d98408974c85cf8aa7d13257ffc2ad878ebb295","tests/no_time_to_init.rs":"e7df75b47897fbf2c860a2e1c1c225b57598b8d1a39125ca897fe8d825bf0338","tests/overflowing_preinit.rs":"7ad4b2274dd9240b53430859a4eb1d2597cf508a5a678333f3d3abbadd2ed4a7","tests/persist_ping_lifetime.rs":"81415dc1d74743f02269f0d0dfa524003147056853f080276972e64a0b761d3c","tests/persist_ping_lifetime_nopanic.rs":"18379d3ffbf4a2c8c684c04ff7a0660b86dfbbb447db2d24dfed6073cb7ddf8f","tests/schema.rs":"ea93fcf68e00ae803031dba9b93edac0713f17e375287c32c35512ba69d5f100","tests/simple.rs":"b099034b0599bdf4650e0fa09991a8413fc5fbf397755fc06c8963d4c7c8dfa6","tests/test-shutdown-blocking.sh":"9b16a01c190c7062474dd92182298a3d9a27928c8fa990340fdd798e6cdb7ab2","tests/upload_timing.rs":"d044fce7c783133e385671ea37d674e5a1b4120cae7b07708dcd825addfa0ee3"},"package":"aa4d34f9ae46bd3e68c5bb672762e7391843daedd609506a70b6b35ac6fea051"} {"files":{"Cargo.toml":"4bc54950917443a58e03b3cfb7b82a5ae696823e000fef651a4e70beab427360","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5627cc81e6187ab6c2b4dff061af16d559edcab64ba786bac39daa69c703c595","src/common_test.rs":"de47b53dcca37985c0a2b8c02daecbf32309aa54f5a4dd9290719c2c1fd0fa55","src/configuration.rs":"4ca9be0a49a9c50f4ebe868d4bfa04fe27619c871a436911f850b4dcf6e7a7b2","src/core_metrics.rs":"dd17b482613894af08b51a2cff6dc1e84a6dbd853c14a55566e6698348941ced","src/lib.rs":"51fbcce68289ff8733e85143692b811683ff3c630e8323d7a0b9701a001ad491","src/net/http_uploader.rs":"43812a70d19a38e8d7a093c8076c2b6345372c3c861b0f3511428762700a65e0","src/net/mod.rs":"e05e61860f5828caa529c3ea75a2fff7371bfa3dce057077a74c09baf41a568a","src/private/event.rs":"02bbebf545695812e5055741cc0b5f3c99eda2039e684e26fcdd5f087ed15fe3","src/private/mod.rs":"0364ecf5f0439443a5b209583f4ff2c474b79f7c253c981ab0b7cdc528368698","src/private/ping.rs":"cbdc57f41fc9d46e56b4dfff91ac683753d1f8b3ecd0aa9bc3419e3595b8b81b","src/system.rs":"6eae5b41c15eba9cad6dbd116abe3519ee3e1fe034e79bdd692b029829a8c384","src/test.rs":"d367c85a106df58272b8a779da1769664ba8a39357fd650d9f21c21855b38906","tests/common/mod.rs":"37cd4c48e140c793b852ae09fb3e812da28a4412977295015bcbffd632fcf294","tests/init_fails.rs":"28fd7726e76ca1295eb0905eca0b2ec65b0accfa28432c9ff90ec8f92616fc79","tests/never_init.rs":"1f33b8ce7ca3514b57b48cc16d98408974c85cf8aa7d13257ffc2ad878ebb295","tests/no_time_to_init.rs":"e7df75b47897fbf2c860a2e1c1c225b57598b8d1a39125ca897fe8d825bf0338","tests/overflowing_preinit.rs":"7ad4b2274dd9240b53430859a4eb1d2597cf508a5a678333f3d3abbadd2ed4a7","tests/persist_ping_lifetime.rs":"81415dc1d74743f02269f0d0dfa524003147056853f080276972e64a0b761d3c","tests/persist_ping_lifetime_nopanic.rs":"18379d3ffbf4a2c8c684c04ff7a0660b86dfbbb447db2d24dfed6073cb7ddf8f","tests/schema.rs":"030ff2b88c56f1f9a3c580277a9311ccc579f25e44f2a89f2afc09d7c4ddf054","tests/simple.rs":"b099034b0599bdf4650e0fa09991a8413fc5fbf397755fc06c8963d4c7c8dfa6"},"package":"3dea54c0198181ff3bd8c7d39bdc69f22a4c0504da5dd9138666edef084e26be"}

View File

@ -13,7 +13,7 @@
edition = "2021" edition = "2021"
rust-version = "1.60" rust-version = "1.60"
name = "glean" name = "glean"
version = "52.3.0" version = "52.2.0"
authors = [ authors = [
"Jan-Erik Rediger <jrediger@mozilla.com>", "Jan-Erik Rediger <jrediger@mozilla.com>",
"The Glean Team <glean-team@mozilla.com>", "The Glean Team <glean-team@mozilla.com>",
@ -43,7 +43,7 @@ features = ["serde"]
version = "0.5" version = "0.5"
[dependencies.glean-core] [dependencies.glean-core]
version = "52.3.0" version = "52.2.0"
[dependencies.inherent] [dependencies.inherent]
version = "1" version = "1"
@ -75,9 +75,10 @@ features = ["v4"]
version = "0.3.0" version = "0.3.0"
[dev-dependencies.env_logger] [dev-dependencies.env_logger]
version = "0.10.0" version = "0.9.0"
features = [ features = [
"auto-color", "termcolor",
"atty",
"humantime", "humantime",
] ]
default-features = false default-features = false

View File

@ -70,7 +70,7 @@ struct GleanEvents {
} }
impl glean_core::OnGleanEvents for GleanEvents { impl glean_core::OnGleanEvents for GleanEvents {
fn initialize_finished(&self) { fn on_initialize_finished(&self) {
// intentionally left empty // intentionally left empty
} }
@ -89,11 +89,6 @@ impl glean_core::OnGleanEvents for GleanEvents {
// intentionally left empty // intentionally left empty
Ok(()) Ok(())
} }
fn shutdown(&self) -> Result<(), glean_core::CallbackError> {
self.upload_manager.shutdown();
Ok(())
}
} }
fn initialize_internal(cfg: Configuration, client_info: ClientInfoMetrics) -> Option<()> { fn initialize_internal(cfg: Configuration, client_info: ClientInfoMetrics) -> Option<()> {

View File

@ -7,15 +7,17 @@
//! This doesn't perform the actual upload but rather handles //! This doesn't perform the actual upload but rather handles
//! retries, upload limitations and error tracking. //! retries, upload limitations and error tracking.
use std::sync::{atomic::Ordering, Arc, Mutex}; use std::sync::{
use std::thread::{self, JoinHandle}; atomic::{AtomicBool, Ordering},
Arc,
};
use std::thread;
use std::time::Duration; use std::time::Duration;
use glean_core::upload::PingUploadTask; use glean_core::upload::PingUploadTask;
pub use glean_core::upload::{PingRequest, UploadResult, UploadTaskAction}; pub use glean_core::upload::{PingRequest, UploadResult, UploadTaskAction};
pub use http_uploader::*; pub use http_uploader::*;
use thread_state::{AtomicState, State};
mod http_uploader; mod http_uploader;
@ -43,8 +45,7 @@ pub(crate) struct UploadManager {
struct Inner { struct Inner {
server_endpoint: String, server_endpoint: String,
uploader: Box<dyn PingUploader + 'static>, uploader: Box<dyn PingUploader + 'static>,
thread_running: AtomicState, thread_running: AtomicBool,
handle: Mutex<Option<JoinHandle<()>>>,
} }
impl UploadManager { impl UploadManager {
@ -62,8 +63,7 @@ impl UploadManager {
inner: Arc::new(Inner { inner: Arc::new(Inner {
server_endpoint, server_endpoint,
uploader: new_uploader, uploader: new_uploader,
thread_running: AtomicState::new(State::Stopped), thread_running: AtomicBool::new(false),
handle: Mutex::new(None),
}), }),
} }
} }
@ -76,12 +76,7 @@ impl UploadManager {
if self if self
.inner .inner
.thread_running .thread_running
.compare_exchange( .compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst)
State::Stopped,
State::Running,
Ordering::SeqCst,
Ordering::SeqCst,
)
.is_err() .is_err()
{ {
return; return;
@ -89,9 +84,7 @@ impl UploadManager {
let inner = Arc::clone(&self.inner); let inner = Arc::clone(&self.inner);
// Need to lock before we start so that noone thinks we're not running. thread::Builder::new()
let mut handle = self.inner.handle.lock().unwrap();
let thread = thread::Builder::new()
.name("glean.upload".into()) .name("glean.upload".into())
.spawn(move || { .spawn(move || {
log::trace!("Started glean.upload thread"); log::trace!("Started glean.upload thread");
@ -108,15 +101,9 @@ impl UploadManager {
let result = inner.uploader.upload(upload_url, request.body, headers); let result = inner.uploader.upload(upload_url, request.body, headers);
// Process the upload response. // Process the upload response.
match glean_core::glean_process_ping_upload_response(doc_id, result) { match glean_core::glean_process_ping_upload_response(doc_id, result) {
UploadTaskAction::Next => (), UploadTaskAction::Next => continue,
UploadTaskAction::End => break, UploadTaskAction::End => break,
} }
let status = inner.thread_running.load(Ordering::SeqCst);
// asked to shut down. let's do it.
if status == State::ShuttingDown {
break;
}
} }
PingUploadTask::Wait { time } => { PingUploadTask::Wait { time } => {
log::trace!("Instructed to wait for {:?}ms", time); log::trace!("Instructed to wait for {:?}ms", time);
@ -130,92 +117,9 @@ impl UploadManager {
} }
} }
// Clear the running flag to signal that this thread is done, // Clear the running flag to signal that this thread is done.
// but only if there's no shutdown thread. inner.thread_running.store(false, Ordering::SeqCst);
let _ = inner.thread_running.compare_exchange(
State::Running,
State::Stopped,
Ordering::SeqCst,
Ordering::SeqCst,
);
}) })
.expect("Failed to spawn Glean's uploader thread"); .expect("Failed to spawn Glean's uploader thread");
*handle = Some(thread);
}
pub(crate) fn shutdown(&self) {
// mark as shutting down.
self.inner
.thread_running
.store(State::ShuttingDown, Ordering::SeqCst);
// take the thread handle out.
let mut handle = self.inner.handle.lock().unwrap();
let thread = handle.take();
if let Some(thread) = thread {
thread
.join()
.expect("couldn't join on the uploader thread.");
}
}
}
mod thread_state {
use std::sync::atomic::{AtomicU8, Ordering};
#[derive(Debug, PartialEq)]
#[repr(u8)]
pub enum State {
Stopped = 0,
Running = 1,
ShuttingDown = 2,
}
#[derive(Debug)]
pub struct AtomicState(AtomicU8);
impl AtomicState {
const fn to_u8(val: State) -> u8 {
val as u8
}
fn from_u8(val: u8) -> State {
#![allow(non_upper_case_globals)]
const U8_Stopped: u8 = State::Stopped as u8;
const U8_Running: u8 = State::Running as u8;
const U8_ShuttingDown: u8 = State::ShuttingDown as u8;
match val {
U8_Stopped => State::Stopped,
U8_Running => State::Running,
U8_ShuttingDown => State::ShuttingDown,
_ => panic!("Invalid enum discriminant"),
}
}
pub const fn new(v: State) -> AtomicState {
AtomicState(AtomicU8::new(Self::to_u8(v)))
}
pub fn load(&self, order: Ordering) -> State {
Self::from_u8(self.0.load(order))
}
pub fn store(&self, val: State, order: Ordering) {
self.0.store(Self::to_u8(val), order)
}
pub fn compare_exchange(
&self,
current: State,
new: State,
success: Ordering,
failure: Ordering,
) -> Result<State, State> {
self.0
.compare_exchange(Self::to_u8(current), Self::to_u8(new), success, failure)
.map(Self::from_u8)
.map_err(Self::from_u8)
}
} }
} }

View File

@ -13,8 +13,8 @@ use serde_json::Value;
use glean::net::UploadResult; use glean::net::UploadResult;
use glean::private::*; use glean::private::*;
use glean::{ use glean::{
traits, ClientInfoMetrics, CommonMetricData, ConfigurationBuilder, HistogramType, MemoryUnit, traits, ClientInfoMetrics, CommonMetricData, Configuration, ConfigurationBuilder,
TimeUnit, HistogramType, MemoryUnit, TimeUnit,
}; };
const SCHEMA_JSON: &str = include_str!("../../../glean.1.schema.json"); const SCHEMA_JSON: &str = include_str!("../../../glean.1.schema.json");
@ -45,10 +45,32 @@ impl traits::ExtraKeys for SomeExtras {
} }
} }
// Create a new instance of Glean with a temporary directory.
// We need to keep the `TempDir` alive, so that it's not deleted before we stop using it.
fn new_glean(configuration: Option<Configuration>) -> tempfile::TempDir {
let dir = tempfile::tempdir().unwrap();
let tmpname = dir.path().to_path_buf();
let cfg = match configuration {
Some(c) => c,
None => ConfigurationBuilder::new(true, tmpname, GLOBAL_APPLICATION_ID)
.with_server_endpoint("invalid-test-host")
.build(),
};
let client_info = ClientInfoMetrics {
app_build: env!("CARGO_PKG_VERSION").to_string(),
app_display_version: env!("CARGO_PKG_VERSION").to_string(),
channel: Some("testing".to_string()),
};
glean::initialize(cfg, client_info);
dir
}
#[test] #[test]
fn validate_against_schema() { fn validate_against_schema() {
let _ = env_logger::builder().try_init();
let schema = load_schema(); let schema = load_schema();
let (s, r) = crossbeam_channel::bounded::<Vec<u8>>(1); let (s, r) = crossbeam_channel::bounded::<Vec<u8>>(1);
@ -79,14 +101,7 @@ fn validate_against_schema() {
.with_server_endpoint("invalid-test-host") .with_server_endpoint("invalid-test-host")
.with_uploader(ValidatingUploader { sender: s }) .with_uploader(ValidatingUploader { sender: s })
.build(); .build();
let _ = new_glean(Some(cfg));
let client_info = ClientInfoMetrics {
app_build: env!("CARGO_PKG_VERSION").to_string(),
app_display_version: env!("CARGO_PKG_VERSION").to_string(),
channel: Some("testing".to_string()),
};
glean::initialize(cfg, client_info);
const PING_NAME: &str = "test-ping"; const PING_NAME: &str = "test-ping";

View File

@ -1,29 +0,0 @@
#!/bin/bash
# Test harness for testing the RLB processes from the outside.
#
# Some behavior can only be observed when properly exiting the process running Glean,
# e.g. when an uploader runs in another thread.
# On exit the threads will be killed, regardless of their state.
# Remove the temporary data path on all exit conditions
cleanup() {
if [ -n "$datapath" ]; then
rm -r "$datapath"
fi
}
trap cleanup INT ABRT TERM EXIT
tmp="${TMPDIR:-/tmp}"
datapath=$(mktemp -d "${tmp}/glean_long_running.XXXX")
cargo run --example long-running -- "$datapath"
count=$(ls -1q "$datapath/pending_pings" | wc -l)
if [[ "$count" -eq 0 ]]; then
echo "test result: ok."
exit 0
else
echo "test result: FAILED."
exit 101
fi

View File

@ -1,225 +0,0 @@
// 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 https://mozilla.org/MPL/2.0/.
//! This integration test should model how the RLB is used when embedded in another Rust application
//! (e.g. FOG/Firefox Desktop).
//!
//! We write a single test scenario per file to avoid any state keeping across runs
//! (different files run as different processes).
mod common;
use std::io::Read;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::thread;
use std::time;
use crossbeam_channel::{bounded, Sender};
use flate2::read::GzDecoder;
use serde_json::Value as JsonValue;
use glean::net;
use glean::ConfigurationBuilder;
pub mod metrics {
#![allow(non_upper_case_globals)]
use glean::{
private::BooleanMetric, private::TimingDistributionMetric, CommonMetricData, Lifetime,
TimeUnit,
};
pub static sample_boolean: once_cell::sync::Lazy<BooleanMetric> =
once_cell::sync::Lazy::new(|| {
BooleanMetric::new(CommonMetricData {
name: "sample_boolean".into(),
category: "test.metrics".into(),
send_in_pings: vec!["validation".into()],
disabled: false,
lifetime: Lifetime::Ping,
..Default::default()
})
});
// The following are duplicated from `glean-core/src/internal_metrics.rs`
// so we can use the test APIs to query them.
pub static send_success: once_cell::sync::Lazy<TimingDistributionMetric> =
once_cell::sync::Lazy::new(|| {
TimingDistributionMetric::new(
CommonMetricData {
name: "send_success".into(),
category: "glean.upload".into(),
send_in_pings: vec!["metrics".into()],
lifetime: Lifetime::Ping,
disabled: false,
dynamic_label: None,
},
TimeUnit::Millisecond,
)
});
pub static send_failure: once_cell::sync::Lazy<TimingDistributionMetric> =
once_cell::sync::Lazy::new(|| {
TimingDistributionMetric::new(
CommonMetricData {
name: "send_failure".into(),
category: "glean.upload".into(),
send_in_pings: vec!["metrics".into()],
lifetime: Lifetime::Ping,
disabled: false,
dynamic_label: None,
},
TimeUnit::Millisecond,
)
});
pub static shutdown_wait: once_cell::sync::Lazy<TimingDistributionMetric> =
once_cell::sync::Lazy::new(|| {
TimingDistributionMetric::new(
CommonMetricData {
name: "shutdown_wait".into(),
category: "glean.validation".into(),
send_in_pings: vec!["metrics".into()],
lifetime: Lifetime::Ping,
disabled: false,
dynamic_label: None,
},
TimeUnit::Millisecond,
)
});
}
mod pings {
use glean::private::PingType;
use once_cell::sync::Lazy;
#[allow(non_upper_case_globals)]
pub static validation: Lazy<PingType> =
Lazy::new(|| glean::private::PingType::new("validation", true, true, vec![]));
}
// Define a fake uploader that sleeps.
#[derive(Debug)]
struct FakeUploader {
calls: AtomicUsize,
sender: Sender<JsonValue>,
}
impl net::PingUploader for FakeUploader {
fn upload(
&self,
_url: String,
body: Vec<u8>,
_headers: Vec<(String, String)>,
) -> net::UploadResult {
let calls = self.calls.fetch_add(1, Ordering::SeqCst);
let decode = |body: Vec<u8>| {
let mut gzip_decoder = GzDecoder::new(&body[..]);
let mut s = String::with_capacity(body.len());
gzip_decoder
.read_to_string(&mut s)
.ok()
.map(|_| &s[..])
.or_else(|| std::str::from_utf8(&body).ok())
.and_then(|payload| serde_json::from_str(payload).ok())
.unwrap()
};
match calls {
// First goes through as is.
0 => net::UploadResult::http_status(200),
// Second briefly sleeps
1 => {
thread::sleep(time::Duration::from_millis(100));
net::UploadResult::http_status(200)
}
// Third one fails
2 => net::UploadResult::http_status(404),
// Fourth one fast again
3 => {
self.sender.send(decode(body)).unwrap();
net::UploadResult::http_status(200)
}
// Last one is the metrics ping, a-ok.
_ => {
self.sender.send(decode(body)).unwrap();
net::UploadResult::http_status(200)
}
}
}
}
/// Test scenario: Different timings for upload on success and failure.
///
/// The app is initialized, in turn Glean gets initialized without problems.
/// A custom ping is submitted multiple times to trigger upload.
/// A metrics ping is submitted to get the upload timing data.
///
/// And later the whole process is shutdown.
#[test]
fn upload_timings() {
common::enable_test_logging();
// Create a custom configuration to use a validating uploader.
let dir = tempfile::tempdir().unwrap();
let tmpname = dir.path().to_path_buf();
let (tx, rx) = bounded(1);
let cfg = ConfigurationBuilder::new(true, tmpname.clone(), "glean-upload-timing")
.with_server_endpoint("invalid-test-host")
.with_use_core_mps(false)
.with_uploader(FakeUploader {
calls: AtomicUsize::new(0),
sender: tx,
})
.build();
common::initialize(cfg);
// Wait for init to finish,
// otherwise we might be to quick with calling `shutdown`.
let _ = metrics::sample_boolean.test_get_value(None);
// fast
pings::validation.submit(None);
// slow
pings::validation.submit(None);
// failed
pings::validation.submit(None);
// fast
pings::validation.submit(None);
// wait for the last ping
let _body = rx.recv().unwrap();
assert_eq!(
3,
metrics::send_success.test_get_value(None).unwrap().count,
"Successful pings: two fast, one slow"
);
assert_eq!(
1,
metrics::send_failure.test_get_value(None).unwrap().count,
"One failed ping"
);
// This is awkward, but it's what gets us very close to just starting a new process with a
// fresh Glean.
// This also calls `glean::shutdown();` internally, waiting on the uploader.
let data_path = Some(tmpname.display().to_string());
glean_core::glean_test_destroy_glean(false, data_path);
let cfg = ConfigurationBuilder::new(true, tmpname, "glean-upload-timing")
.with_server_endpoint("invalid-test-host")
.with_use_core_mps(false)
.build();
common::initialize(cfg);
assert_eq!(
1,
metrics::shutdown_wait.test_get_value(None).unwrap().count,
"Measured time waiting for shutdown exactly once"
);
}

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "MPL-2.0" license = "MPL-2.0"
[dependencies] [dependencies]
glean = "52.3.0" glean = "52.2.0"
log = "0.4" log = "0.4"
nserror = { path = "../../../xpcom/rust/nserror" } nserror = { path = "../../../xpcom/rust/nserror" }
nsstring = { path = "../../../xpcom/rust/nsstring" } nsstring = { path = "../../../xpcom/rust/nsstring" }

View File

@ -9,7 +9,7 @@ license = "MPL-2.0"
[dependencies] [dependencies]
bincode = "1.0" bincode = "1.0"
chrono = "0.4.10" chrono = "0.4.10"
glean = "52.3.0" glean = "52.2.0"
inherent = "1.0.0" inherent = "1.0.0"
log = "0.4" log = "0.4"
nsstring = { path = "../../../../xpcom/rust/nsstring", optional = true } nsstring = { path = "../../../../xpcom/rust/nsstring", optional = true }

View File

@ -307,7 +307,9 @@ mod test {
None, None,
); );
metric.get(&"1".repeat(72)).set(true); metric
.get("this_string_has_more_than_thirty_characters")
.set(true);
assert_eq!( assert_eq!(
1, 1,

View File

@ -26,7 +26,7 @@ add_task(async () => {
undefined, undefined,
Glean.testOnlyIpc.aLabeledCounter.__other__.testGetValue() Glean.testOnlyIpc.aLabeledCounter.__other__.testGetValue()
); );
Glean.testOnlyIpc.aLabeledCounter["1".repeat(72)].add(3); Glean.testOnlyIpc.aLabeledCounter.InvalidLabel.add(3);
Assert.throws( Assert.throws(
() => Glean.testOnlyIpc.aLabeledCounter.__other__.testGetValue(), () => Glean.testOnlyIpc.aLabeledCounter.__other__.testGetValue(),
/NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/, /NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/,
@ -40,7 +40,7 @@ add_task(async () => {
{ {
a_label: 1, a_label: 1,
another_label: 2, another_label: 2,
["1".repeat(72)]: 3, InvalidLabel: 3,
}, },
value value
); );

View File

@ -101,7 +101,7 @@ add_task({ skip_if: () => runningInParent }, async function run_child_stuff() {
// Has to be different from aLabeledCounter so the error we record doesn't // Has to be different from aLabeledCounter so the error we record doesn't
// get in the way. // get in the way.
Glean.testOnlyIpc.anotherLabeledCounter["1".repeat(72)].add(INVALID_COUNTERS); Glean.testOnlyIpc.anotherLabeledCounter.InvalidLabel.add(INVALID_COUNTERS);
Glean.testOnlyIpc.irate.addToNumerator(IRATE_NUMERATOR); Glean.testOnlyIpc.irate.addToNumerator(IRATE_NUMERATOR);
Glean.testOnlyIpc.irate.addToDenominator(IRATE_DENOMINATOR); Glean.testOnlyIpc.irate.addToDenominator(IRATE_DENOMINATOR);
@ -221,7 +221,7 @@ add_task(
); );
Assert.deepEqual( Assert.deepEqual(
{ {
["1".repeat(72)]: INVALID_COUNTERS, InvalidLabel: INVALID_COUNTERS,
}, },
value value
); );

View File

@ -268,19 +268,18 @@ add_task(async function test_fog_labels_conform() {
Glean.testOnly.mabelsLabelMaker["dot.separated"].testGetValue() Glean.testOnly.mabelsLabelMaker["dot.separated"].testGetValue()
); );
Glean.testOnly.mabelsLabelMaker.camelCase.set("wednesday"); Glean.testOnly.mabelsLabelMaker.camelCase.set("wednesday");
Assert.equal(
"wednesday",
Glean.testOnly.mabelsLabelMaker.camelCase.testGetValue()
);
const veryLong = "1".repeat(72);
Glean.testOnly.mabelsLabelMaker[veryLong].set("seventy-two");
Assert.throws( Assert.throws(
() => Glean.testOnly.mabelsLabelMaker[veryLong].testGetValue(), () => Glean.testOnly.mabelsLabelMaker.camelCase.testGetValue(),
/NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/, /NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/,
"Should throw because of an invalid label." "Should throw because of an invalid label."
); );
// This test should _now_ throw because we are calling data after an invalid Assert.throws(
// label has been set. () => Glean.testOnly.mabelsLabelMaker.__other__.testGetValue(),
/NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/,
"Should throw because of an invalid label."
);
// This test _should_ throw because we are calling data after an invalid label
// has been set.
Assert.throws( Assert.throws(
() => Glean.testOnly.mabelsLabelMaker["dot.separated"].testGetValue(), () => Glean.testOnly.mabelsLabelMaker["dot.separated"].testGetValue(),
/NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/, /NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/,
@ -309,7 +308,7 @@ add_task(async function test_fog_labeled_boolean_works() {
undefined, undefined,
Glean.testOnly.mabelsLikeBalloons.__other__.testGetValue() Glean.testOnly.mabelsLikeBalloons.__other__.testGetValue()
); );
Glean.testOnly.mabelsLikeBalloons["1".repeat(72)].set(true); Glean.testOnly.mabelsLikeBalloons.InvalidLabel.set(true);
Assert.throws( Assert.throws(
() => Glean.testOnly.mabelsLikeBalloons.__other__.testGetValue(), () => Glean.testOnly.mabelsLikeBalloons.__other__.testGetValue(),
/NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/, /NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/,
@ -338,7 +337,7 @@ add_task(async function test_fog_labeled_counter_works() {
undefined, undefined,
Glean.testOnly.mabelsKitchenCounters.__other__.testGetValue() Glean.testOnly.mabelsKitchenCounters.__other__.testGetValue()
); );
Glean.testOnly.mabelsKitchenCounters["1".repeat(72)].add(1); Glean.testOnly.mabelsKitchenCounters.InvalidLabel.add(1);
Assert.throws( Assert.throws(
() => Glean.testOnly.mabelsKitchenCounters.__other__.testGetValue(), () => Glean.testOnly.mabelsKitchenCounters.__other__.testGetValue(),
/NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/, /NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/,
@ -367,7 +366,7 @@ add_task(async function test_fog_labeled_string_works() {
undefined, undefined,
Glean.testOnly.mabelsBalloonStrings.__other__.testGetValue() Glean.testOnly.mabelsBalloonStrings.__other__.testGetValue()
); );
Glean.testOnly.mabelsBalloonStrings["1".repeat(72)].set("valid"); Glean.testOnly.mabelsBalloonStrings.InvalidLabel.set("valid");
Assert.throws( Assert.throws(
() => Glean.testOnly.mabelsBalloonStrings.__other__.testGetValue(), () => Glean.testOnly.mabelsBalloonStrings.__other__.testGetValue(),
/NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/ /NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/

View File

@ -71,7 +71,7 @@ add_task({ skip_if: () => runningInParent }, async function run_child_stuff() {
COUNTERS_WITH_JUNK_ON_THEM COUNTERS_WITH_JUNK_ON_THEM
); );
Glean.testOnly.mabelsBathroomCounters["1".repeat(72)].add(INVALID_COUNTERS); Glean.testOnly.mabelsBathroomCounters.InvalidLabel.add(INVALID_COUNTERS);
Glean.testOnlyIpc.irate.addToNumerator(44); Glean.testOnlyIpc.irate.addToNumerator(44);
Glean.testOnlyIpc.irate.addToDenominator(14); Glean.testOnlyIpc.irate.addToDenominator(14);

View File

@ -381,9 +381,7 @@ add_task(async function test_jog_labeled_boolean_works() {
Assert.equal(false, Glean.jogCat.jogLabeledBool.label_2.testGetValue()); Assert.equal(false, Glean.jogCat.jogLabeledBool.label_2.testGetValue());
// What about invalid/__other__? // What about invalid/__other__?
Assert.equal(undefined, Glean.jogCat.jogLabeledBool.__other__.testGetValue()); Assert.equal(undefined, Glean.jogCat.jogLabeledBool.__other__.testGetValue());
Glean.jogCat.jogLabeledBool.NowValidLabel.set(true); Glean.jogCat.jogLabeledBool.InvalidLabel.set(true);
Assert.ok(Glean.jogCat.jogLabeledBool.NowValidLabel.testGetValue());
Glean.jogCat.jogLabeledBool["1".repeat(72)].set(true);
Assert.throws( Assert.throws(
() => Glean.jogCat.jogLabeledBool.__other__.testGetValue(), () => Glean.jogCat.jogLabeledBool.__other__.testGetValue(),
/NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/, /NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/,
@ -452,7 +450,7 @@ add_task(async function test_jog_labeled_counter_works() {
undefined, undefined,
Glean.jogCat.jogLabeledCounter.__other__.testGetValue() Glean.jogCat.jogLabeledCounter.__other__.testGetValue()
); );
Glean.jogCat.jogLabeledCounter["1".repeat(72)].add(1); Glean.jogCat.jogLabeledCounter.InvalidLabel.add(1);
Assert.throws( Assert.throws(
() => Glean.jogCat.jogLabeledCounter.__other__.testGetValue(), () => Glean.jogCat.jogLabeledCounter.__other__.testGetValue(),
/NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/, /NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/,
@ -490,7 +488,7 @@ add_task(async function test_jog_labeled_counter_with_static_labels_works() {
undefined, undefined,
Glean.jogCat.jogLabeledCounterWithLabels.__other__.testGetValue() Glean.jogCat.jogLabeledCounterWithLabels.__other__.testGetValue()
); );
Glean.jogCat.jogLabeledCounterWithLabels["1".repeat(72)].add(1); Glean.jogCat.jogLabeledCounterWithLabels.InvalidLabel.add(1);
// TODO:(bug 1766515) - This should throw. // TODO:(bug 1766515) - This should throw.
/*Assert.throws( /*Assert.throws(
() => Glean.jogCat.jogLabeledCounterWithLabels.__other__.testGetValue(), () => Glean.jogCat.jogLabeledCounterWithLabels.__other__.testGetValue(),
@ -526,7 +524,7 @@ add_task(async function test_jog_labeled_string_works() {
undefined, undefined,
Glean.jogCat.jogLabeledString.__other__.testGetValue() Glean.jogCat.jogLabeledString.__other__.testGetValue()
); );
Glean.jogCat.jogLabeledString["1".repeat(72)].set("valid"); Glean.jogCat.jogLabeledString.InvalidLabel.set("valid");
Assert.throws( Assert.throws(
() => Glean.jogCat.jogLabeledString.__other__.testGetValue(), () => Glean.jogCat.jogLabeledString.__other__.testGetValue(),
/NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/ /NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/
@ -563,7 +561,7 @@ add_task(async function test_jog_labeled_string_with_labels_works() {
undefined, undefined,
Glean.jogCat.jogLabeledStringWithLabels.__other__.testGetValue() Glean.jogCat.jogLabeledStringWithLabels.__other__.testGetValue()
); );
Glean.jogCat.jogLabeledStringWithLabels["1".repeat(72)].set("valid"); Glean.jogCat.jogLabeledStringWithLabels.InvalidLabel.set("valid");
// TODO:(bug 1766515) - This should throw. // TODO:(bug 1766515) - This should throw.
/*Assert.throws( /*Assert.throws(
() => Glean.jogCat.jogLabeledStringWithLabels.__other__.testGetValue(), () => Glean.jogCat.jogLabeledStringWithLabels.__other__.testGetValue(),

View File

@ -154,12 +154,12 @@ add_task({ skip_if: () => runningInParent }, async function run_child_stuff() {
Glean.jogIpc.jogLabeledCounter.label_1.add(COUNTERS_1); Glean.jogIpc.jogLabeledCounter.label_1.add(COUNTERS_1);
Glean.jogIpc.jogLabeledCounter.label_2.add(COUNTERS_2); Glean.jogIpc.jogLabeledCounter.label_2.add(COUNTERS_2);
Glean.jogIpc.jogLabeledCounterErr["1".repeat(72)].add(INVALID_COUNTERS); Glean.jogIpc.jogLabeledCounterErr.InvalidLabel.add(INVALID_COUNTERS);
Glean.jogIpc.jogLabeledCounterWithLabels.label_1.add(COUNTERS_1); Glean.jogIpc.jogLabeledCounterWithLabels.label_1.add(COUNTERS_1);
Glean.jogIpc.jogLabeledCounterWithLabels.label_2.add(COUNTERS_2); Glean.jogIpc.jogLabeledCounterWithLabels.label_2.add(COUNTERS_2);
Glean.jogIpc.jogLabeledCounterWithLabelsErr["1".repeat(72)].add( Glean.jogIpc.jogLabeledCounterWithLabelsErr.InvalidLabel.add(
INVALID_COUNTERS INVALID_COUNTERS
); );