Bug 1781030 - Upgrade to Glean v51.0.1. r=perry.mcmanis,supply-chain-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D152626
This commit is contained in:
Jan-Erik Rediger 2022-08-01 10:50:47 +00:00
parent 760010bb23
commit 94b2463ce2
123 changed files with 500 additions and 959 deletions

13
Cargo.lock generated
View File

@ -58,9 +58,9 @@ checksum = "85965b6739a430150bdd138e2374a98af0c3ee0d030b3bb7fc3bddff58d0102e"
[[package]]
name = "android_logger"
version = "0.11.0"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b74b7ddf197de32e415d197aa21c1c0cb36e01e4794fd801302280ac7847ee02"
checksum = "b5e9dd62f37dea550caf48c77591dc50bd1a378ce08855be1a0c42a97b7550fb"
dependencies = [
"android_log-sys",
"env_logger 0.9.0",
@ -2203,9 +2203,9 @@ dependencies = [
[[package]]
name = "glean"
version = "50.1.3"
version = "51.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe54494f067655870956431d2a6942e56611da53d67101dd64847445b29367b0"
checksum = "a20e782acaa1771ea4de48aa8bcf3421ae1e77c36dbae7595428fc2e333d0df5"
dependencies = [
"chrono",
"crossbeam-channel",
@ -2223,16 +2223,15 @@ dependencies = [
[[package]]
name = "glean-core"
version = "50.1.3"
version = "51.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f32fadcf37284fdaf70d1e9d0afd753b8a5c02348fd2e366e81e2b6f9ba84091"
checksum = "127156f8df21363a476e37b7adf3fe89995cf48fda281563fe7ae1bdb1160760"
dependencies = [
"android_logger",
"bincode",
"chrono",
"crossbeam-channel",
"env_logger 0.9.0",
"ffi-support",
"flate2",
"log",
"once_cell",

View File

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

23
gfx/wr/Cargo.lock generated
View File

@ -31,9 +31,9 @@ checksum = "85965b6739a430150bdd138e2374a98af0c3ee0d030b3bb7fc3bddff58d0102e"
[[package]]
name = "android_logger"
version = "0.11.0"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b74b7ddf197de32e415d197aa21c1c0cb36e01e4794fd801302280ac7847ee02"
checksum = "b5e9dd62f37dea550caf48c77591dc50bd1a378ce08855be1a0c42a97b7550fb"
dependencies = [
"android_log-sys",
"env_logger",
@ -714,16 +714,6 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "ffi-support"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27838c6815cfe9de2d3aeb145ffd19e565f577414b33f3bdbf42fe040e9e0ff6"
dependencies = [
"lazy_static",
"log",
]
[[package]]
name = "flate2"
version = "1.0.23"
@ -876,9 +866,9 @@ dependencies = [
[[package]]
name = "glean"
version = "50.1.3"
version = "51.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe54494f067655870956431d2a6942e56611da53d67101dd64847445b29367b0"
checksum = "a20e782acaa1771ea4de48aa8bcf3421ae1e77c36dbae7595428fc2e333d0df5"
dependencies = [
"chrono",
"crossbeam-channel",
@ -896,16 +886,15 @@ dependencies = [
[[package]]
name = "glean-core"
version = "50.1.3"
version = "51.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f32fadcf37284fdaf70d1e9d0afd753b8a5c02348fd2e366e81e2b6f9ba84091"
checksum = "127156f8df21363a476e37b7adf3fe89995cf48fda281563fe7ae1bdb1160760"
dependencies = [
"android_logger",
"bincode",
"chrono",
"crossbeam-channel",
"env_logger",
"ffi-support",
"flate2",
"log",
"once_cell",

View File

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

View File

@ -130,7 +130,7 @@ pth:xpcom/geckoprocesstypes_generator
pth:xpcom/idl-parser
# glean-sdk may not be installable if a wheel isn't available
# and it has to be built from source.
pypi-optional:glean-sdk==50.1.3:telemetry will not be collected
pypi-optional:glean-sdk==51.0.1:telemetry will not be collected
# Mach gracefully handles the case where `psutil` is unavailable.
# 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).

View File

@ -7,6 +7,12 @@ criteria = "safe-to-deploy"
version = "0.11.0"
notes = "Small crate, wrapping Android log functionality, reviewed by janerik"
[[audits.android_logger]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "0.11.0 -> 0.11.1"
notes = "Small crate, wrapping Android log functionality, now switched to properly using MaybeUninit"
[[audits.android_system_properties]]
who = "Nicolas Silva <nical@fastmail.com>"
criteria = "safe-to-deploy"
@ -122,6 +128,12 @@ 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-core]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
@ -140,6 +152,12 @@ 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.linked-hash-map]]
who = "Aria Beingessner <a.beingessner@gmail.com>"
criteria = "safe-to-deploy"

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"896268b277c2cd333293139e868abac82c39983de9aa56aead4464c38239b66a","LICENSE-APACHE":"99938c5864dd33decb62ab20fd883a9b00181d768ae887a4f19b2d0015c41dc9","LICENSE-MIT":"35043211d1b7be8f7e3f9cad27d981f2189ba9a39d9527b275b3c9740298dfe2","README.md":"bf2e6227790edeb5959c2be250b71d1a197a3a344dc5fc1638fbb39c73bdfd21","src/lib.rs":"e3a0a6bb68d7bad681a978274b612e77cecc41112b448209a09c96b5b33d029e","tests/config_log_level.rs":"8aae2c7decbcf12a2a454486c9d4dd4a82a20e01d327c4abf4e9cfded973159d","tests/default_init.rs":"ef18c9ea38687a178623c11acfa3d34d16b9030eaad337ab9ed6a609a2c42ca2","tests/multiple_init.rs":"a6ed4986a758b7b2322c6ad0a18ec99fd06521a6c8767a6622eab2cbf9be601e"},"package":"b74b7ddf197de32e415d197aa21c1c0cb36e01e4794fd801302280ac7847ee02"}
{"files":{"Cargo.toml":"abdac5f9f4574b24d387e1a7d6e44cfd0d1bf9a95ebd858f51dc02bf5604c582","LICENSE-APACHE":"99938c5864dd33decb62ab20fd883a9b00181d768ae887a4f19b2d0015c41dc9","LICENSE-MIT":"35043211d1b7be8f7e3f9cad27d981f2189ba9a39d9527b275b3c9740298dfe2","README.md":"bf2e6227790edeb5959c2be250b71d1a197a3a344dc5fc1638fbb39c73bdfd21","src/lib.rs":"b789a29f5f55ccdc2ba9428747a39ce2a649e0c35ac30c983b0fa6c5f549e855","tests/config_log_level.rs":"dbe26e82c497031f47804ed59dfcdb5d09af7354591f90ea89b46315e7d2edc9","tests/default_init.rs":"e5c77dbcf3dc2d9e21e5c48c190e6cdcdea7d8eecea8c8ce513ca98223c46b49","tests/multiple_init.rs":"42adfe70b2f951a3b3f051235709013124df613a7967ca5bad998fc5356b8b9f"},"package":"b5e9dd62f37dea550caf48c77591dc50bd1a378ce08855be1a0c42a97b7550fb"}

View File

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

View File

@ -72,15 +72,15 @@ extern crate log;
extern crate env_logger;
use log::{Level, Log, Metadata, Record};
#[cfg(target_os = "android")]
use log_ffi::LogPriority;
use log::{Level, Log, Metadata, Record};
use std::ffi::{CStr, CString};
use std::mem;
use std::fmt;
use std::mem::{self, MaybeUninit};
use std::ptr;
pub use env_logger::filter::{Filter, Builder as FilterBuilder};
pub use env_logger::filter::{Builder as FilterBuilder, Filter};
pub use env_logger::fmt::Formatter;
pub(crate) type FormatFn = Box<dyn Fn(&mut dyn fmt::Write, &Record) -> fmt::Result + Sync + Send>;
@ -115,7 +115,6 @@ impl AndroidLogger {
}
}
static ANDROID_LOGGER: OnceCell<AndroidLogger> = OnceCell::new();
const LOGGING_TAG_MAX_LEN: usize = 23;
@ -136,22 +135,23 @@ impl Log for AndroidLogger {
}
fn log(&self, record: &Record) {
let config = self.config
.get_or_init(Config::default);
let config = self.config.get_or_init(Config::default);
if !config.filter_matches(record) {
return;
}
// tag must not exceed LOGGING_TAG_MAX_LEN
#[allow(deprecated)] // created an issue #35 for this
let mut tag_bytes: [u8; LOGGING_TAG_MAX_LEN + 1] = unsafe { mem::uninitialized() };
let mut tag_bytes: [MaybeUninit<u8>; LOGGING_TAG_MAX_LEN + 1] = uninit_array();
let module_path = record.module_path().unwrap_or_default().to_owned();
// If no tag was specified, use module name
let custom_tag = &config.tag;
let tag = custom_tag.as_ref().map(|s| s.as_bytes()).unwrap_or_else(|| module_path.as_bytes());
let tag = custom_tag
.as_ref()
.map(|s| s.as_bytes())
.unwrap_or_else(|| module_path.as_bytes());
// truncate the tag here to fit into LOGGING_TAG_MAX_LEN
self.fill_tag_bytes(&mut tag_bytes, tag);
@ -181,21 +181,19 @@ impl Log for AndroidLogger {
}
impl AndroidLogger {
fn fill_tag_bytes(&self, array: &mut [u8], tag: &[u8]) {
fn fill_tag_bytes(&self, array: &mut [MaybeUninit<u8>], tag: &[u8]) {
if tag.len() > LOGGING_TAG_MAX_LEN {
for (input, output) in tag.iter()
for (input, output) in tag
.iter()
.take(LOGGING_TAG_MAX_LEN - 2)
.chain(b"..\0".iter())
.zip(array.iter_mut())
{
*output = *input;
output.write(*input);
}
} else {
for (input, output) in tag.iter()
.chain(b"\0".iter())
.zip(array.iter_mut())
{
*output = *input;
for (input, output) in tag.iter().chain(b"\0".iter()).zip(array.iter_mut()) {
output.write(*input);
}
}
}
@ -256,13 +254,15 @@ impl Config {
}
}
struct PlatformLogWriter<'a> {
#[cfg(target_os = "android")] priority: LogPriority,
#[cfg(not(target_os = "android"))] priority: Level,
pub struct PlatformLogWriter<'a> {
#[cfg(target_os = "android")]
priority: LogPriority,
#[cfg(not(target_os = "android"))]
priority: Level,
len: usize,
last_newline_index: usize,
tag: &'a CStr,
buffer: [u8; LOGGING_MSG_MAX_LEN + 1],
buffer: [MaybeUninit<u8>; LOGGING_MSG_MAX_LEN + 1],
}
impl<'a> PlatformLogWriter<'a> {
@ -280,7 +280,7 @@ impl<'a> PlatformLogWriter<'a> {
len: 0,
last_newline_index: 0,
tag,
buffer: unsafe { mem::uninitialized() },
buffer: uninit_array(),
}
}
@ -292,7 +292,7 @@ impl<'a> PlatformLogWriter<'a> {
len: 0,
last_newline_index: 0,
tag,
buffer: unsafe { mem::uninitialized() },
buffer: uninit_array(),
}
}
@ -324,7 +324,7 @@ impl<'a> PlatformLogWriter<'a> {
}
/// Flush everything remaining to android logger.
fn flush(&mut self) {
pub fn flush(&mut self) {
let total_len = self.len;
if total_len == 0 {
@ -338,21 +338,22 @@ impl<'a> PlatformLogWriter<'a> {
/// Output buffer up until the \0 which will be placed at `len` position.
fn output_specified_len(&mut self, len: usize) {
let mut last_byte: u8 = b'\0';
let mut last_byte = MaybeUninit::new(b'\0');
mem::swap(&mut last_byte, unsafe {
self.buffer.get_unchecked_mut(len)
});
let msg: &CStr = unsafe { CStr::from_ptr(mem::transmute(self.buffer.as_ptr())) };
let msg: &CStr = unsafe { CStr::from_ptr(self.buffer.as_ptr().cast()) };
android_log(self.priority, self.tag, msg);
*unsafe { self.buffer.get_unchecked_mut(len) } = last_byte;
unsafe { *self.buffer.get_unchecked_mut(len) = last_byte };
}
/// Copy `len` bytes from `index` position to starting position.
fn copy_bytes_to_start(&mut self, index: usize, len: usize) {
let src = unsafe { self.buffer.as_ptr().add(index) };
let dst = self.buffer.as_mut_ptr();
let src = unsafe { self.buffer.as_ptr().add(index) };
unsafe { ptr::copy(src, dst, len) };
}
}
@ -371,7 +372,7 @@ impl<'a> fmt::Write for PlatformLogWriter<'a> {
.zip(incomming_bytes)
.enumerate()
.fold(None, |acc, (i, (output, input))| {
*output = *input;
output.write(*input);
if *input == b'\n' {
Some(i)
} else {
@ -409,7 +410,9 @@ impl<'a> fmt::Write for PlatformLogWriter<'a> {
/// This action does not require initialization. However, without initialization it
/// will use the default filter, which allows all logs.
pub fn log(record: &Record) {
ANDROID_LOGGER.get_or_init(AndroidLogger::default).log(record)
ANDROID_LOGGER
.get_or_init(AndroidLogger::default)
.log(record)
}
/// Initializes the global logger with an android logger.
@ -430,6 +433,12 @@ pub fn init_once(config: Config) {
}
}
// FIXME: When `maybe_uninit_uninit_array ` is stabilized, use it instead of this helper
fn uninit_array<const N: usize, T>() -> [MaybeUninit<T>; N] {
// SAFETY: Array contains MaybeUninit, which is fine to be uninit
unsafe { MaybeUninit::uninit().assume_init() }
}
#[cfg(test)]
mod tests {
use super::*;
@ -489,12 +498,12 @@ mod tests {
let logger = AndroidLogger::new(Config::default());
let too_long_tag: [u8; LOGGING_TAG_MAX_LEN + 20] = [b'a'; LOGGING_TAG_MAX_LEN + 20];
let mut result: [u8; LOGGING_TAG_MAX_LEN + 1] = Default::default();
let mut result: [MaybeUninit<u8>; LOGGING_TAG_MAX_LEN + 1] = uninit_array();
logger.fill_tag_bytes(&mut result, &too_long_tag);
let mut expected_result = [b'a'; LOGGING_TAG_MAX_LEN - 2].to_vec();
expected_result.extend("..\0".as_bytes());
assert_eq!(result.to_vec(), expected_result);
assert_eq!(unsafe { assume_init_slice(&result) }, expected_result);
}
#[test]
@ -502,12 +511,12 @@ mod tests {
let logger = AndroidLogger::new(Config::default());
let short_tag: [u8; 3] = [b'a'; 3];
let mut result: [u8; LOGGING_TAG_MAX_LEN + 1] = Default::default();
let mut result: [MaybeUninit<u8>; LOGGING_TAG_MAX_LEN + 1] = uninit_array();
logger.fill_tag_bytes(&mut result, &short_tag);
let mut expected_result = short_tag.to_vec();
expected_result.push(0);
assert_eq!(result.to_vec()[..4], expected_result);
assert_eq!(unsafe { assume_init_slice(&result[..4]) }, expected_result);
}
#[test]
@ -535,7 +544,10 @@ mod tests {
// Should have flushed up until the last newline.
assert_eq!(writer.len, 3);
assert_eq!(writer.last_newline_index, 0);
assert_eq!(&writer.buffer.to_vec()[..writer.len], "\n90".as_bytes());
assert_eq!(
unsafe { assume_init_slice(&writer.buffer[..writer.len]) },
"\n90".as_bytes()
);
writer.temporal_flush();
// Should have flushed all remaining bytes.
@ -578,7 +590,7 @@ mod tests {
writer.output_specified_len(5);
assert_eq!(
writer.buffer[..log_string.len()].to_vec(),
unsafe { assume_init_slice(&writer.buffer[..log_string.len()]) },
log_string.as_bytes()
);
}
@ -592,7 +604,10 @@ mod tests {
writer.copy_bytes_to_start(3, 2);
assert_eq!(writer.buffer[..10].to_vec(), "3423456789".as_bytes());
assert_eq!(
unsafe { assume_init_slice(&writer.buffer[..10]) },
"3423456789".as_bytes()
);
}
#[test]
@ -607,7 +622,7 @@ mod tests {
writer.copy_bytes_to_start(10, 0);
assert_eq!(
writer.buffer[..test_string.len()].to_vec(),
unsafe { assume_init_slice(&writer.buffer[..test_string.len()]) },
test_string.as_bytes()
);
}
@ -615,4 +630,8 @@ mod tests {
fn get_tag_writer() -> PlatformLogWriter<'static> {
PlatformLogWriter::new(Level::Warn, CStr::from_bytes_with_nul(b"tag\0").unwrap())
}
unsafe fn assume_init_slice<T>(slice: &[MaybeUninit<T>]) -> &[T] {
&*(slice as *const [MaybeUninit<T>] as *const [T])
}
}

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "glean-core"
version = "50.1.3"
version = "51.0.1"
authors = [
"Jan-Erik Rediger <jrediger@mozilla.com>",
"The Glean Team <glean-team@mozilla.com>",
@ -46,9 +46,6 @@ features = ["serde"]
[dependencies.crossbeam-channel]
version = "0.5"
[dependencies.ffi-support]
version = "0.4.0"
[dependencies.flate2]
version = "1.0.19"
@ -113,9 +110,6 @@ version = "3.1.0"
version = "0.19.3"
features = ["builtin-bindgen"]
[features]
rkv-safe-mode = []
[target."cfg(not(target_os = \"android\"))".dependencies.env_logger]
version = "0.9.0"
features = [

View File

@ -10,6 +10,7 @@ use std::path::Path;
use std::str;
use std::sync::RwLock;
use rkv::migrator::Migrator;
use rkv::StoreOptions;
/// Unwrap a `Result`s `Ok` value or do the specified action.
@ -27,42 +28,14 @@ macro_rules! unwrap_or {
};
}
// Select the LMDB-powered storage backend when the feature is not activated.
#[cfg(not(feature = "rkv-safe-mode"))]
mod backend {
use std::path::Path;
/// cbindgen:ignore
pub type Rkv = rkv::Rkv<rkv::backend::SafeModeEnvironment>;
/// cbindgen:ignore
pub type SingleStore = rkv::SingleStore<rkv::backend::SafeModeDatabase>;
/// cbindgen:ignore
pub type Writer<'t> = rkv::Writer<rkv::backend::SafeModeRwTransaction<'t>>;
/// cbindgen:ignore
pub type Rkv = rkv::Rkv<rkv::backend::LmdbEnvironment>;
/// cbindgen:ignore
pub type SingleStore = rkv::SingleStore<rkv::backend::LmdbDatabase>;
/// cbindgen:ignore
pub type Writer<'t> = rkv::Writer<rkv::backend::LmdbRwTransaction<'t>>;
pub fn rkv_new(path: &Path) -> Result<Rkv, rkv::StoreError> {
Rkv::new::<rkv::backend::Lmdb>(path)
}
/// No migration necessary when staying with LMDB.
pub fn migrate(_path: &Path, _dst_env: &Rkv) {
// Intentionally left empty.
}
}
// Select the "safe mode" storage backend when the feature is activated.
#[cfg(feature = "rkv-safe-mode")]
mod backend {
use rkv::migrator::Migrator;
use std::{fs, path::Path};
/// cbindgen:ignore
pub type Rkv = rkv::Rkv<rkv::backend::SafeModeEnvironment>;
/// cbindgen:ignore
pub type SingleStore = rkv::SingleStore<rkv::backend::SafeModeDatabase>;
/// cbindgen:ignore
pub type Writer<'t> = rkv::Writer<rkv::backend::SafeModeRwTransaction<'t>>;
pub fn rkv_new(path: &Path) -> Result<Rkv, rkv::StoreError> {
pub fn rkv_new(path: &Path) -> std::result::Result<Rkv, rkv::StoreError> {
match Rkv::new::<rkv::backend::SafeMode>(path) {
// An invalid file can mean:
// 1. An empty file.
@ -78,9 +51,9 @@ mod backend {
}
other => other,
}
}
}
fn delete_and_log(path: &Path, msg: &str) {
fn delete_and_log(path: &Path, msg: &str) {
if let Err(err) = fs::remove_file(path) {
match err.kind() {
std::io::ErrorKind::NotFound => {
@ -89,25 +62,25 @@ mod backend {
_ => log::warn!("{}", msg),
}
}
}
}
fn delete_lmdb_database(path: &Path) {
fn delete_lmdb_database(path: &Path) {
let datamdb = path.join("data.mdb");
delete_and_log(&datamdb, "Failed to delete old data.");
let lockmdb = path.join("lock.mdb");
delete_and_log(&lockmdb, "Failed to delete old lock.");
}
}
/// Migrate from LMDB storage to safe-mode storage.
///
/// This migrates the data once, then deletes the LMDB storage.
/// The safe-mode storage must be empty for it to work.
/// Existing data will not be overwritten.
/// If the destination database is not empty the LMDB database is deleted
/// without migrating data.
/// This is a no-op if no LMDB database file exists.
pub fn migrate(path: &Path, dst_env: &Rkv) {
/// Migrate from LMDB storage to safe-mode storage.
///
/// This migrates the data once, then deletes the LMDB storage.
/// The safe-mode storage must be empty for it to work.
/// Existing data will not be overwritten.
/// If the destination database is not empty the LMDB database is deleted
/// without migrating data.
/// This is a no-op if no LMDB database file exists.
pub fn migrate(path: &Path, dst_env: &Rkv) {
use rkv::{MigrateError, StoreError};
log::debug!("Migrating files in {}", path.display());
@ -168,7 +141,6 @@ mod backend {
}
log::debug!("Migration ended. Safe-mode database in {}", path.display());
}
}
use crate::metrics::Metric;
@ -176,7 +148,6 @@ use crate::CommonMetricData;
use crate::Glean;
use crate::Lifetime;
use crate::Result;
use backend::*;
pub struct Database {
/// Handle to the database environment.
@ -250,21 +221,6 @@ impl Database {
/// It also loads any Lifetime::Ping data that might be
/// persisted, in case `delay_ping_lifetime_io` is set.
pub fn new(data_path: &Path, delay_ping_lifetime_io: bool) -> Result<Self> {
#[cfg(all(windows, not(feature = "rkv-safe-mode")))]
{
// The underlying lmdb wrapper implementation
// cannot actually handle non-UTF8 paths on Windows.
// It will unconditionally panic if passed one.
// See
// https://github.com/mozilla/lmdb-rs/blob/df1c2f56e3088f097c719c57b9925ab51e26f3f4/src/environment.rs#L43-L53
//
// To avoid this, in case we're using LMDB on Windows (that's just testing now though),
// we simply error out earlier.
if data_path.to_str().is_none() {
return Err(crate::Error::utf8_error());
}
}
let path = data_path.join("db");
log::debug!("Database path: {:?}", path.display());
let file_size = database_size(&path);
@ -839,8 +795,6 @@ mod test {
let res = Database::new(&path, false);
#[cfg(feature = "rkv-safe-mode")]
{
assert!(
res.is_ok(),
"Database should succeed at {}: {:?}",
@ -849,17 +803,6 @@ mod test {
);
}
#[cfg(not(feature = "rkv-safe-mode"))]
{
assert!(
res.is_err(),
"Database should fail at {}: {:?}",
path.display(),
res
);
}
}
#[test]
#[cfg(target_os = "linux")]
fn linux_invalid_utf8_panicfree() {
@ -1491,27 +1434,6 @@ mod test {
);
}
/// LDMB ignores an empty database file just fine.
#[cfg(not(feature = "rkv-safe-mode"))]
#[test]
fn empty_data_file() {
let dir = tempdir().unwrap();
// Create database directory structure.
let database_dir = dir.path().join("db");
fs::create_dir_all(&database_dir).expect("create database dir");
// Create empty database file.
let datamdb = database_dir.join("data.mdb");
let f = fs::File::create(datamdb).expect("create database file");
drop(f);
Database::new(dir.path(), false).unwrap();
assert!(dir.path().exists());
}
#[cfg(feature = "rkv-safe-mode")]
mod safe_mode {
use std::fs::File;

View File

@ -7,8 +7,6 @@ use std::fmt::{self, Display};
use std::io;
use std::result;
use ffi_support::{handle_map::HandleError, ExternError};
use rkv::StoreError;
/// A specialized [`Result`] type for this crate's operations.
@ -32,9 +30,6 @@ pub enum ErrorKind {
/// Lifetime conversion failed
Lifetime(i32),
/// FFI-Support error
Handle(HandleError),
/// IO error
IoError(io::Error),
@ -107,7 +102,6 @@ impl Display for Error {
use ErrorKind::*;
match self.kind() {
Lifetime(l) => write!(f, "Lifetime conversion from {} failed", l),
Handle(e) => write!(f, "Invalid handle: {}", e),
IoError(e) => write!(f, "An I/O error occurred: {}", e),
Rkv(e) => write!(f, "An Rkv error occurred: {}", e),
Json(e) => write!(f, "A JSON error occurred: {}", e),
@ -133,14 +127,6 @@ impl From<ErrorKind> for Error {
}
}
impl From<HandleError> for Error {
fn from(error: HandleError) -> Error {
Error {
kind: ErrorKind::Handle(error),
}
}
}
impl From<io::Error> for Error {
fn from(error: io::Error) -> Error {
Error {
@ -157,12 +143,6 @@ impl From<StoreError> for Error {
}
}
impl From<Error> for ExternError {
fn from(error: Error) -> ExternError {
ffi_support::ExternError::new_error(ffi_support::ErrorCode::new(42), format!("{}", error))
}
}
impl From<serde_json::error::Error> for Error {
fn from(error: serde_json::error::Error) -> Error {
Error {

View File

@ -157,16 +157,13 @@ pub fn test_get_num_recorded_errors(
glean: &Glean,
meta: &CommonMetricData,
error: ErrorType,
ping_name: Option<&str>,
) -> Result<i32, String> {
let use_ping_name = ping_name.unwrap_or(&meta.send_in_pings[0]);
let metric = get_error_metric_for_metric(meta, error);
metric.get_value(glean, Some(use_ping_name)).ok_or_else(|| {
metric.get_value(glean, Some("metrics")).ok_or_else(|| {
format!(
"No error recorded for {} in '{}' store",
"No error recorded for {} in 'metrics' store",
meta.base_identifier(),
use_ping_name
)
})
}
@ -221,24 +218,19 @@ mod test {
expected_invalid_labels_errors,
);
for store in &["store1", "store2", "metrics"] {
let invalid_val =
get_error_metric_for_metric(string_metric.meta(), ErrorType::InvalidValue);
let invalid_label =
get_error_metric_for_metric(string_metric.meta(), ErrorType::InvalidLabel);
for &store in &["store1", "store2", "metrics"] {
assert_eq!(
Ok(expected_invalid_values_errors),
test_get_num_recorded_errors(
&glean,
string_metric.meta(),
ErrorType::InvalidValue,
Some(store)
)
Some(expected_invalid_values_errors),
invalid_val.get_value(&glean, Some(store))
);
assert_eq!(
Ok(expected_invalid_labels_errors),
test_get_num_recorded_errors(
&glean,
string_metric.meta(),
ErrorType::InvalidLabel,
Some(store)
)
Some(expected_invalid_labels_errors),
invalid_label.get_value(&glean, Some(store))
);
}
}

View File

@ -306,24 +306,6 @@ impl EventDatabase {
Ok(())
}
/// **Test-only API (exported for FFI purposes).**
///
/// Returns whether there are any events currently stored for the given even
/// metric.
///
/// This doesn't clear the stored value.
pub fn test_has_value<'a>(&'a self, meta: &'a CommonMetricData, store_name: &str) -> bool {
record_coverage(&meta.base_identifier());
self.event_stores
.read()
.unwrap() // safe unwrap, only error case is poisoning
.get(&store_name.to_string())
.into_iter()
.flatten()
.any(|event| event.name == meta.name && event.category == meta.category)
}
/// **Test-only API (exported for FFI purposes).**
///
/// Gets the vector of currently stored events for the given event metric in

View File

@ -242,7 +242,7 @@ interface CounterMetric {
i32? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
// Different resolutions supported by the time related metric types
@ -277,7 +277,7 @@ interface TimespanMetric {
i64? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
interface BooleanMetric {
@ -287,7 +287,7 @@ interface BooleanMetric {
boolean? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
interface StringMetric {
@ -297,7 +297,7 @@ interface StringMetric {
string? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
interface LabeledCounter {
@ -305,7 +305,7 @@ interface LabeledCounter {
CounterMetric get(string label);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
interface LabeledBoolean {
@ -313,7 +313,7 @@ interface LabeledBoolean {
BooleanMetric get(string label);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
interface LabeledString {
@ -321,7 +321,7 @@ interface LabeledString {
StringMetric get(string label);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
interface StringListMetric {
@ -333,7 +333,7 @@ interface StringListMetric {
sequence<string>? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
interface UrlMetric {
@ -343,7 +343,7 @@ interface UrlMetric {
string? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
interface UuidMetric {
@ -355,7 +355,7 @@ interface UuidMetric {
string? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
interface QuantityMetric {
@ -365,7 +365,7 @@ interface QuantityMetric {
i64? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
// A snapshot of all buckets and the accumulated sum of a distribution.
@ -398,7 +398,7 @@ interface TimingDistributionMetric {
DistributionData? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
// Different resolutions supported by the memory related metric types
@ -423,7 +423,7 @@ interface MemoryDistributionMetric {
DistributionData? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
// Different kinds of histograms.
@ -441,7 +441,7 @@ interface CustomDistributionMetric {
DistributionData? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
// Representation of a date, time and timezone.
@ -465,7 +465,7 @@ interface DatetimeMetric {
string? test_get_value_as_string(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
// Represents the recorded data for a single event.
@ -498,7 +498,7 @@ interface EventMetric {
sequence<RecordedEvent>? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
dictionary Rate {
@ -515,7 +515,7 @@ interface RateMetric {
Rate? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
interface DenominatorMetric {
@ -525,7 +525,7 @@ interface DenominatorMetric {
i32? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
interface NumeratorMetric {
@ -535,7 +535,7 @@ interface NumeratorMetric {
Rate? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};
interface TextMetric {
@ -545,5 +545,5 @@ interface TextMetric {
string? test_get_value(optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error, optional string? ping_name = null);
i32 test_get_num_recorded_errors(ErrorType error);
};

View File

@ -123,12 +123,11 @@ impl BooleanMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}

View File

@ -152,12 +152,11 @@ impl CounterMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}

View File

@ -210,12 +210,11 @@ impl CustomDistributionMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}

View File

@ -316,12 +316,11 @@ impl DatetimeMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}

View File

@ -129,12 +129,11 @@ impl DenominatorMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}

View File

@ -160,12 +160,11 @@ impl EventMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}

View File

@ -270,11 +270,10 @@ where
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.submetric.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.submetric.meta(), error).unwrap_or(0)
})
}
}

View File

@ -259,12 +259,11 @@ impl MemoryDistributionMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}

View File

@ -87,7 +87,7 @@ impl NumeratorMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
self.0.test_get_num_recorded_errors(error, ping_name)
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
self.0.test_get_num_recorded_errors(error)
}
}

View File

@ -115,12 +115,11 @@ impl QuantityMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}

View File

@ -180,12 +180,11 @@ impl RateMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}

View File

@ -129,12 +129,11 @@ impl StringMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}
@ -169,7 +168,7 @@ mod test {
assert_eq!(
1,
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow, None)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow)
.unwrap()
);
}

View File

@ -188,12 +188,11 @@ impl StringListMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}

View File

@ -133,12 +133,11 @@ impl TextMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}
@ -173,7 +172,7 @@ mod test {
assert_eq!(
1,
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow, None)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow)
.unwrap()
);
}

View File

@ -297,12 +297,11 @@ impl TimespanMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}

View File

@ -461,12 +461,11 @@ impl TimingDistributionMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}

View File

@ -156,12 +156,11 @@ impl UrlMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}
@ -213,7 +212,7 @@ mod test {
assert_eq!(
1,
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow, None)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow)
.unwrap()
);
}
@ -238,8 +237,7 @@ mod test {
assert_eq!(
1,
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue, None)
.unwrap()
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue).unwrap()
);
}
@ -297,8 +295,8 @@ mod test {
assert_eq!(
incorrects.len(),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue, None)
.unwrap() as usize
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue).unwrap()
as usize
);
for correct in corrects.into_iter() {

View File

@ -148,12 +148,11 @@ impl UuidMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors(&self, error: ErrorType, ping_name: Option<String>) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
crate::block_on_dispatcher();
crate::core::with_glean(|glean| {
test_get_num_recorded_errors(glean, self.meta(), error, ping_name.as_deref())
.unwrap_or(0)
test_get_num_recorded_errors(glean, self.meta(), error).unwrap_or(0)
})
}
}

View File

@ -35,15 +35,9 @@ pub trait Boolean {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - represents the optional name of the ping to retrieve the
/// metric for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors reported.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -39,15 +39,9 @@ pub trait Counter {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - represents the optional name of the ping to retrieve the
/// metric for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors reported.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -50,15 +50,9 @@ pub trait CustomDistribution {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - represents the optional name of the ping to retrieve the
/// metric for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors recorded.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -44,15 +44,9 @@ pub trait Datetime {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - represents the optional name of the ping to retrieve the
/// metric for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors reported.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -110,15 +110,9 @@ pub trait Event {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - represents the optional name of the ping to retrieve the
/// metric for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors reported.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -32,15 +32,9 @@ where
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - represents the optional name of the ping to retrieve the
/// metric for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors reported.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -46,15 +46,9 @@ pub trait MemoryDistribution {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - represents the optional name of the ping to retrieve the
/// metric for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors recorded.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -39,15 +39,9 @@ pub trait Numerator {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - the optional name of the ping to retrieve the metric
/// for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors reported.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -39,15 +39,9 @@ pub trait Quantity {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - represents the optional name of the ping to retrieve the
/// metric for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors reported.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -49,15 +49,9 @@ pub trait Rate {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - the optional name of the ping to retrieve the metric
/// for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors reported.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -42,15 +42,9 @@ pub trait String {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - represents the optional name of the ping to retrieve the
/// metric for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors reported.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -52,15 +52,9 @@ pub trait StringList {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - represents the optional name of the ping to retrieve the
/// metric for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors recorded.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -42,15 +42,9 @@ pub trait Text {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - represents the optional name of the ping to retrieve the
/// metric for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors reported.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -59,15 +59,9 @@ pub trait Timespan {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - represents the optional name of the ping to retrieve the
/// metric for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors reported.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -65,15 +65,9 @@ pub trait TimingDistribution {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - represents the optional name of the ping to retrieve the
/// metric for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors recorded.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -43,15 +43,9 @@ pub trait Url {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - represents the optional name of the ping to retrieve the
/// metric for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors reported.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -38,15 +38,9 @@ pub trait Uuid {
/// # Arguments
///
/// * `error` - The type of error
/// * `ping_name` - represents the optional name of the ping to retrieve the
/// metric for. Defaults to the first value in `send_in_pings`.
///
/// # Returns
///
/// The number of errors reported.
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32;
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
}

View File

@ -123,7 +123,7 @@ fn counters_must_not_increment_when_passed_zero_or_negative() {
// Make sure that the errors have been recorded
assert_eq!(
Ok(2),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue, None)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue)
);
}

View File

@ -143,13 +143,9 @@ mod linear {
assert_eq!(1, snapshot.values[&3]);
// No errors should be reported.
assert!(test_get_num_recorded_errors(
&glean,
metric.meta(),
ErrorType::InvalidValue,
Some("store1")
)
.is_err());
assert!(
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue).is_err()
);
}
#[test]
@ -191,12 +187,7 @@ mod linear {
// 1 error should be reported.
assert_eq!(
Ok(1),
test_get_num_recorded_errors(
&glean,
metric.meta(),
ErrorType::InvalidValue,
Some("store1")
)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue)
);
}
@ -354,13 +345,9 @@ mod exponential {
assert_eq!(1, snapshot.values[&3]);
// No errors should be reported.
assert!(test_get_num_recorded_errors(
&glean,
metric.meta(),
ErrorType::InvalidValue,
Some("store1")
)
.is_err());
assert!(
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue).is_err()
);
}
#[test]
@ -402,12 +389,7 @@ mod exponential {
// 1 error should be reported.
assert_eq!(
Ok(1),
test_get_num_recorded_errors(
&glean,
metric.meta(),
ErrorType::InvalidValue,
Some("store1")
)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue)
);
}

View File

@ -167,7 +167,7 @@ fn can_record_error_for_submetric() {
// Make sure that the errors have been recorded
assert_eq!(
Ok(1),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow, None)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow)
);
}

View File

@ -136,13 +136,7 @@ fn the_accumulate_samples_api_correctly_stores_memory_values() {
assert_eq!(1, snapshot.values[&3024]);
// No errors should be reported.
assert!(test_get_num_recorded_errors(
&glean,
metric.meta(),
ErrorType::InvalidValue,
Some("store1")
)
.is_err());
assert!(test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue).is_err());
}
#[test]
@ -183,11 +177,6 @@ fn the_accumulate_samples_api_correctly_handles_negative_values() {
// 1 error should be reported.
assert_eq!(
Ok(1),
test_get_num_recorded_errors(
&glean,
metric.meta(),
ErrorType::InvalidValue,
Some("store1")
)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue)
);
}

View File

@ -113,6 +113,6 @@ fn quantities_must_not_set_when_passed_negative() {
// Make sure that the errors have been recorded
assert_eq!(
Ok(1),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue, None)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue)
);
}

View File

@ -24,9 +24,7 @@ fn rate_smoke() {
metric.add_to_numerator_sync(&glean, 0);
metric.add_to_denominator_sync(&glean, 0);
assert!(
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue, None).is_err(),
);
assert!(test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue).is_err());
// Adding a negative value errors.
metric.add_to_numerator_sync(&glean, -1);
@ -34,7 +32,7 @@ fn rate_smoke() {
assert_eq!(
Ok(2),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue, None),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue),
);
// Getting the value returns 0s if that's all we have.
@ -61,16 +59,14 @@ fn numerator_smoke() {
// Adding 0 doesn't error.
metric.add_to_numerator_sync(&glean, 0);
assert!(
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue, None).is_err()
);
assert!(test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue).is_err());
// Adding a negative value errors.
metric.add_to_numerator_sync(&glean, -1);
assert_eq!(
Ok(1),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue, None),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue),
);
// Getting the value returns 0s if that's all we have.
@ -124,12 +120,8 @@ fn denominator_smoke() {
denom.add_sync(&glean, 7);
// no errors.
assert!(
test_get_num_recorded_errors(&glean, num1.meta(), ErrorType::InvalidValue, None).is_err()
);
assert!(
test_get_num_recorded_errors(&glean, num2.meta(), ErrorType::InvalidValue, None).is_err()
);
assert!(test_get_num_recorded_errors(&glean, num1.meta(), ErrorType::InvalidValue).is_err());
assert!(test_get_num_recorded_errors(&glean, num2.meta(), ErrorType::InvalidValue).is_err());
// Getting the value returns 0s if that's all we have.
let data = num1.get_value(&glean, None).unwrap();

View File

@ -116,6 +116,6 @@ fn long_string_values_are_truncated() {
// Make sure that the errors have been recorded
assert_eq!(
Ok(1),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow, None)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow)
);
}

View File

@ -128,7 +128,7 @@ fn long_string_values_are_truncated() {
// Ensure the error has been recorded.
assert_eq!(
Ok(1),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow, None)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow)
);
metric.set_sync(&glean, vec![test_string.clone()]);
@ -142,7 +142,7 @@ fn long_string_values_are_truncated() {
// Ensure the error has been recorded.
assert_eq!(
Ok(2),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow, None)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow)
);
}
@ -170,9 +170,7 @@ fn disabled_string_lists_dont_record() {
assert_eq!(None, metric.get_value(&glean, "store1"));
// Ensure no error was recorded.
assert!(
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue, None).is_err()
);
assert!(test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue).is_err());
}
#[test]
@ -206,7 +204,7 @@ fn string_lists_dont_exceed_max_items() {
// Ensure we recorded the error.
assert_eq!(
Ok(1),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue, None)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue)
);
// Try to set it to a list that's too long. Ensure it cuts off at 20 elements.
@ -220,7 +218,7 @@ fn string_lists_dont_exceed_max_items() {
assert_eq!(
Ok(2),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue, None)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue)
);
}
@ -243,7 +241,5 @@ fn set_does_not_record_error_when_receiving_empty_list() {
assert_eq!(Some(vec![]), metric.get_value(&glean, "store1"));
// Ensure we didn't record an error.
assert!(
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue, None).is_err()
);
assert!(test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue).is_err());
}

View File

@ -110,6 +110,6 @@ fn long_text_values_are_truncated() {
// Make sure that the errors have been recorded
assert_eq!(
Ok(1),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow, None)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow)
);
}

View File

@ -115,9 +115,7 @@ fn second_timer_run_is_skipped() {
metric.set_stop(&glean, duration);
// No error should be recorded here: we had no prior value stored.
assert!(
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidState, None).is_err()
);
assert!(test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidState).is_err());
let first_value = metric.get_value(&glean, "store1").unwrap();
assert_eq!(duration, first_value);
@ -132,7 +130,7 @@ fn second_timer_run_is_skipped() {
// new measurement was dropped.
assert_eq!(
Ok(1),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidState, None)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidState)
);
}
@ -281,7 +279,7 @@ fn set_raw_time_does_nothing_when_timer_running() {
// Make sure that the error has been recorded
assert_eq!(
Ok(1),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidState, None)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidState)
);
}
@ -324,7 +322,7 @@ fn timespan_is_not_tracked_across_upload_toggle() {
// Make sure that the error has been recorded
assert_eq!(
Ok(1),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidState, None)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidState)
);
}
@ -348,6 +346,6 @@ fn time_cannot_go_backwards() {
assert!(metric.get_value(&glean, "test1").is_none());
assert_eq!(
Ok(1),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue, None),
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue),
);
}

View File

@ -134,12 +134,7 @@ fn timing_distributions_must_not_accumulate_negative_values() {
// Make sure that the errors have been recorded
assert_eq!(
Ok(1),
test_get_num_recorded_errors(
&glean,
metric.meta(),
ErrorType::InvalidValue,
Some("store1")
)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue)
);
}
@ -180,13 +175,7 @@ fn the_accumulate_samples_api_correctly_stores_timing_values() {
assert_eq!(1, snapshot.values[&2784941737]);
// No errors should be reported.
assert!(test_get_num_recorded_errors(
&glean,
metric.meta(),
ErrorType::InvalidValue,
Some("store1")
)
.is_err());
assert!(test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue).is_err());
}
#[test]
@ -223,12 +212,7 @@ fn the_accumulate_samples_api_correctly_handles_negative_values() {
// 1 error should be reported.
assert_eq!(
Ok(1),
test_get_num_recorded_errors(
&glean,
metric.meta(),
ErrorType::InvalidValue,
Some("store1")
)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue)
);
}
@ -269,12 +253,7 @@ fn the_accumulate_samples_api_correctly_handles_overflowing_values() {
// 1 error should be reported.
assert_eq!(
Ok(1),
test_get_num_recorded_errors(
&glean,
metric.meta(),
ErrorType::InvalidOverflow,
Some("store1")
)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow)
);
}
@ -331,12 +310,7 @@ fn stopping_non_existing_id_records_an_error() {
// 1 error should be reported.
assert_eq!(
Ok(1),
test_get_num_recorded_errors(
&glean,
metric.meta(),
ErrorType::InvalidState,
Some("store1")
)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidState)
);
}
@ -377,13 +351,7 @@ fn the_accumulate_raw_samples_api_correctly_stores_timing_values() {
assert_eq!(1, snapshot.values[&2784941737]);
// No errors should be reported.
assert!(test_get_num_recorded_errors(
&glean,
metric.meta(),
ErrorType::InvalidState,
Some("store1")
)
.is_err());
assert!(test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidState).is_err());
}
#[test]
@ -430,11 +398,6 @@ fn raw_samples_api_error_cases() {
// No errors should be reported.
assert_eq!(
Ok(1),
test_get_num_recorded_errors(
&glean,
metric.meta(),
ErrorType::InvalidOverflow,
Some("store1")
)
test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow)
);
}

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"e118fe27a3ad1a7c2ec5127996ea93636b0b87567c2425f8bef98eaf917866e6","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5bc5b1c46695f628e1023662752272e938a963b535d5686bd1ecc433f9e018c4","src/common_test.rs":"68f6d408cb7b683fa32c8b38a4df1e6c45bfd77c0c90ca35976ea7548bbc4b2f","src/configuration.rs":"37ad5b3e7d4e31dd04a7d6690179168b5f2768d87dd36056dee5d08bdbe20fb2","src/core_metrics.rs":"76ac5350cb6f82d9a193d519b085a08f138dceba77da3514bd0c636bcdefefca","src/lib.rs":"e342d497d60abceca3c84d35523a54d187b0282220a112da53e4ab1cf76da205","src/net/http_uploader.rs":"43812a70d19a38e8d7a093c8076c2b6345372c3c861b0f3511428762700a65e0","src/net/mod.rs":"86cbcb0b46f9d13923a20db9e482b65da49d7daa4e335a3f3092f1d760f572b0","src/private/event.rs":"f6cd799c7764c53510180a1cef6a5a9b435fae27b87270519d5b4e59201e8ecc","src/private/mod.rs":"0364ecf5f0439443a5b209583f4ff2c474b79f7c253c981ab0b7cdc528368698","src/private/ping.rs":"cbdc57f41fc9d46e56b4dfff91ac683753d1f8b3ecd0aa9bc3419e3595b8b81b","src/system.rs":"ff23a5b94f52dab484342dfed702412bc29ab1bbfd5af326033d8e07e7b9075f","src/test.rs":"30d62d967c56a7ca76c097e27bfb6d6d3779ccd5d374cf5a07a04216e4e0880b","tests/common/mod.rs":"37cd4c48e140c793b852ae09fb3e812da28a4412977295015bcbffd632fcf294","tests/init_fails.rs":"9b78226a4e3220de5b64a205a97b8d5778d1700391b5b71c7819b6cdd120747e","tests/never_init.rs":"1f33b8ce7ca3514b57b48cc16d98408974c85cf8aa7d13257ffc2ad878ebb295","tests/no_time_to_init.rs":"494dcddce49f279c6508f484ee59cf8bb83e7324de07bdbc1142f2a066b7f6a1","tests/overflowing_preinit.rs":"396206d5078b7e6c148bbf2aecb0f963cfaa4d7eff3fc7bf6590125076ee6113","tests/persist_ping_lifetime.rs":"2297d4b208e14188e6dcca2d4806b805cfc7dd824d21bd143a7803b95e0709f4","tests/persist_ping_lifetime_nopanic.rs":"06f1f3ca3b8a6c8b7fc4d6fc48d0e1d2ccffd32139f080db0a95003e9edd507d","tests/schema.rs":"a96089f828928b6be1fad7815e3269f5693af1b773e570312b357a29af28122a","tests/simple.rs":"a1d72af899293390bb955ca379baafb89c29bb746630409f8c51f453d222dbad"},"package":"fe54494f067655870956431d2a6942e56611da53d67101dd64847445b29367b0"}
{"files":{"Cargo.toml":"cca6235962158e52716cffef30031b7bd6d9c6ace3f06267d2e3da34d24f7c15","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5bc5b1c46695f628e1023662752272e938a963b535d5686bd1ecc433f9e018c4","src/common_test.rs":"68f6d408cb7b683fa32c8b38a4df1e6c45bfd77c0c90ca35976ea7548bbc4b2f","src/configuration.rs":"37ad5b3e7d4e31dd04a7d6690179168b5f2768d87dd36056dee5d08bdbe20fb2","src/core_metrics.rs":"76ac5350cb6f82d9a193d519b085a08f138dceba77da3514bd0c636bcdefefca","src/lib.rs":"e342d497d60abceca3c84d35523a54d187b0282220a112da53e4ab1cf76da205","src/net/http_uploader.rs":"43812a70d19a38e8d7a093c8076c2b6345372c3c861b0f3511428762700a65e0","src/net/mod.rs":"86cbcb0b46f9d13923a20db9e482b65da49d7daa4e335a3f3092f1d760f572b0","src/private/event.rs":"02bbebf545695812e5055741cc0b5f3c99eda2039e684e26fcdd5f087ed15fe3","src/private/mod.rs":"0364ecf5f0439443a5b209583f4ff2c474b79f7c253c981ab0b7cdc528368698","src/private/ping.rs":"cbdc57f41fc9d46e56b4dfff91ac683753d1f8b3ecd0aa9bc3419e3595b8b81b","src/system.rs":"ff23a5b94f52dab484342dfed702412bc29ab1bbfd5af326033d8e07e7b9075f","src/test.rs":"d70c6aaadd529bec2fa3029c4138193865e598ad054ec636a4b5baae48177f99","tests/common/mod.rs":"37cd4c48e140c793b852ae09fb3e812da28a4412977295015bcbffd632fcf294","tests/init_fails.rs":"9b78226a4e3220de5b64a205a97b8d5778d1700391b5b71c7819b6cdd120747e","tests/never_init.rs":"1f33b8ce7ca3514b57b48cc16d98408974c85cf8aa7d13257ffc2ad878ebb295","tests/no_time_to_init.rs":"494dcddce49f279c6508f484ee59cf8bb83e7324de07bdbc1142f2a066b7f6a1","tests/overflowing_preinit.rs":"396206d5078b7e6c148bbf2aecb0f963cfaa4d7eff3fc7bf6590125076ee6113","tests/persist_ping_lifetime.rs":"2297d4b208e14188e6dcca2d4806b805cfc7dd824d21bd143a7803b95e0709f4","tests/persist_ping_lifetime_nopanic.rs":"06f1f3ca3b8a6c8b7fc4d6fc48d0e1d2ccffd32139f080db0a95003e9edd507d","tests/schema.rs":"a96089f828928b6be1fad7815e3269f5693af1b773e570312b357a29af28122a","tests/simple.rs":"a1d72af899293390bb955ca379baafb89c29bb746630409f8c51f453d222dbad"},"package":"a20e782acaa1771ea4de48aa8bcf3421ae1e77c36dbae7595428fc2e333d0df5"}

View File

@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "glean"
version = "50.1.3"
version = "51.0.1"
authors = [
"Jan-Erik Rediger <jrediger@mozilla.com>",
"The Glean Team <glean-team@mozilla.com>",
@ -41,7 +41,7 @@ features = ["serde"]
version = "0.5"
[dependencies.glean-core]
version = "50.1.3"
version = "51.0.1"
[dependencies.inherent]
version = "1"
@ -85,14 +85,11 @@ default-features = false
version = "1.0.19"
[dev-dependencies.jsonschema-valid]
version = "0.4.0"
version = "0.5.0"
[dev-dependencies.tempfile]
version = "3.1.0"
[features]
rkv-safe-mode = ["glean-core/rkv-safe-mode"]
[badges.circle-ci]
branch = "main"
repository = "mozilla/glean"

View File

@ -38,6 +38,18 @@ impl<K: traits::ExtraKeys> EventMetric<K> {
}
}
/// The public constructor used by runtime-defined metrics.
pub fn with_runtime_extra_keys(
meta: glean_core::CommonMetricData,
allowed_extra_keys: Vec<String>,
) -> Self {
let inner = glean_core::metrics::EventMetric::new(meta, allowed_extra_keys);
Self {
inner,
extra_keys: PhantomData,
}
}
/// Record a new event with a provided timestamp.
///
/// It's the caller's responsibility to ensure the timestamp comes from the same clock source.
@ -132,6 +144,57 @@ mod test {
assert_eq!(None, data[2].extra);
}
#[test]
fn with_runtime_extra_keys() {
let _lock = lock_test();
let _t = new_glean(None, true);
#[derive(Default, Debug, Clone, Hash, Eq, PartialEq)]
struct RuntimeExtra {}
impl glean_core::traits::ExtraKeys for RuntimeExtra {
const ALLOWED_KEYS: &'static [&'static str] = &[];
fn into_ffi_extra(self) -> HashMap<String, String> {
HashMap::new()
}
}
let metric: EventMetric<RuntimeExtra> = EventMetric::with_runtime_extra_keys(
CommonMetricData {
name: "event".into(),
category: "test".into(),
send_in_pings: vec!["test1".into()],
..Default::default()
},
vec!["key1".into(), "key2".into()],
);
let map1 = HashMap::from([("key1".into(), "1".into())]);
metric.record_with_time(0, map1);
let map2 = HashMap::from([("key1".into(), "1".into()), ("key2".into(), "2".into())]);
metric.record_with_time(1, map2);
metric.record_with_time(2, HashMap::new());
let data = metric.test_get_value(None).expect("no event recorded");
assert_eq!(3, data.len());
assert!(data[0].timestamp <= data[1].timestamp);
assert!(data[1].timestamp <= data[2].timestamp);
let mut map = HashMap::new();
map.insert("key1".into(), "1".into());
assert_eq!(Some(map), data[0].extra);
let mut map = HashMap::new();
map.insert("key1".into(), "1".into());
map.insert("key2".into(), "2".into());
assert_eq!(Some(map), data[1].extra);
assert_eq!(None, data[2].extra);
}
}
#[inherent]
@ -154,12 +217,7 @@ impl<K: traits::ExtraKeys> traits::Event for EventMetric<K> {
self.inner.test_get_value(ping_name)
}
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32 {
let ping_name = ping_name.into().map(|s| s.to_string());
self.inner.test_get_num_recorded_errors(error, ping_name)
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
self.inner.test_get_num_recorded_errors(error)
}
}

View File

@ -1127,7 +1127,7 @@ fn test_boolean_get_num_errors() {
});
// Check specifically for an invalid label
let result = metric.test_get_num_recorded_errors(ErrorType::InvalidLabel, None);
let result = metric.test_get_num_recorded_errors(ErrorType::InvalidLabel);
assert_eq!(result, 0);
}

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "MPL-2.0"
[dependencies]
glean = { version = "50.1.2", features = ["rkv-safe-mode"] }
glean = "51.0.1"
log = "0.4"
nserror = { path = "../../../xpcom/rust/nserror" }
nsstring = { path = "../../../xpcom/rust/nsstring" }

View File

@ -8,7 +8,7 @@ publish = false
[dependencies]
bincode = "1.0"
chrono = "0.4.10"
glean = "50.1.3"
glean = "51.0.1"
inherent = "1.0.0"
log = "0.4"
nsstring = { path = "../../../../xpcom/rust/nsstring", optional = true }

View File

@ -17,12 +17,8 @@ pub extern "C" fn fog_boolean_test_get_value(id: u32, ping_name: &nsACString) ->
}
#[no_mangle]
pub extern "C" fn fog_boolean_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let err = with_metric!(BOOLEAN_MAP, id, metric, test_get_errors!(metric, ping_name));
pub extern "C" fn fog_boolean_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
let err = with_metric!(BOOLEAN_MAP, id, metric, test_get_errors!(metric));
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -22,11 +22,7 @@ pub unsafe extern "C" fn fog_counter_test_get_value(id: u32, ping_name: &nsACStr
}
#[no_mangle]
pub extern "C" fn fog_counter_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let err = with_metric!(COUNTER_MAP, id, metric, test_get_errors!(metric, ping_name));
pub extern "C" fn fog_counter_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
let err = with_metric!(COUNTER_MAP, id, metric, test_get_errors!(metric));
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -69,14 +69,14 @@ pub extern "C" fn fog_custom_distribution_accumulate_samples_signed(
#[no_mangle]
pub extern "C" fn fog_custom_distribution_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let err = with_metric!(
CUSTOM_DISTRIBUTION_MAP,
id,
metric,
test_get_errors!(metric, ping_name)
test_get_errors!(metric)
);
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -60,16 +60,7 @@ pub extern "C" fn fog_datetime_set(id: u32, dt: &FogDatetime) {
}
#[no_mangle]
pub extern "C" fn fog_datetime_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let err = with_metric!(
DATETIME_MAP,
id,
metric,
test_get_errors!(metric, ping_name)
);
pub extern "C" fn fog_datetime_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
let err = with_metric!(DATETIME_MAP, id, metric, test_get_errors!(metric));
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -22,16 +22,7 @@ pub unsafe extern "C" fn fog_denominator_test_get_value(id: u32, ping_name: &nsA
}
#[no_mangle]
pub extern "C" fn fog_denominator_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let err = with_metric!(
DENOMINATOR_MAP,
id,
metric,
test_get_errors!(metric, ping_name)
);
pub extern "C" fn fog_denominator_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
let err = with_metric!(DENOMINATOR_MAP, id, metric, test_get_errors!(metric));
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -60,17 +60,8 @@ pub unsafe extern "C" fn fog_event_test_has_value(id: u32, ping_name: &nsACStrin
}
#[no_mangle]
pub extern "C" fn fog_event_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let storage = if ping_name.is_empty() {
None
} else {
Some(ping_name.to_utf8().into_owned())
};
let err = metric_maps::event_test_get_error(id, storage);
pub extern "C" fn fog_event_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
let err = metric_maps::event_test_get_error(id);
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -136,30 +136,8 @@ macro_rules! test_get {
/// # Arguments
///
/// * `$metric` - The metric to test.
/// * `$storage` - the storage name to look into, an nsACString.
macro_rules! test_get_errors {
($metric:path, $storage:ident) => {{
let storage = if $storage.is_empty() {
None
} else {
Some($storage.to_utf8())
};
// Note: I'd really appreciate a trick that'd get the compiler to
// double-check I haven't missed any error types here.
test_get_errors_string!($metric, storage)
}};
}
/// Check the provided metric in the provided storage for errors.
/// On finding one, return an error string.
///
/// # Arguments
///
/// * `$metric` - The metric to test.
/// * `$storage` - the storage name to look into, an Option<String>
macro_rules! test_get_errors_string {
($metric:path, $storage:ident) => {{
($metric:path) => {{
let error_types = [
glean::ErrorType::InvalidValue,
glean::ErrorType::InvalidLabel,
@ -168,7 +146,7 @@ macro_rules! test_get_errors_string {
];
let mut error_str = None;
for &error_type in error_types.iter() {
let num_errors = $metric.test_get_num_recorded_errors(error_type, $storage.as_deref());
let num_errors = $metric.test_get_num_recorded_errors(error_type);
if num_errors > 0 {
error_str = Some(format!(
"Metric had {} error(s) of type {}!",

View File

@ -51,14 +51,14 @@ pub extern "C" fn fog_memory_distribution_accumulate(id: u32, sample: u64) {
#[no_mangle]
pub extern "C" fn fog_memory_distribution_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let err = with_metric!(
MEMORY_DISTRIBUTION_MAP,
id,
metric,
test_get_errors!(metric, ping_name)
test_get_errors!(metric)
);
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -29,16 +29,7 @@ pub unsafe extern "C" fn fog_numerator_test_get_value(
}
#[no_mangle]
pub extern "C" fn fog_numerator_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let err = with_metric!(
NUMERATOR_MAP,
id,
metric,
test_get_errors!(metric, ping_name)
);
pub extern "C" fn fog_numerator_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
let err = with_metric!(NUMERATOR_MAP, id, metric, test_get_errors!(metric));
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -22,16 +22,7 @@ pub extern "C" fn fog_quantity_test_get_value(id: u32, ping_name: &nsACString) -
}
#[no_mangle]
pub extern "C" fn fog_quantity_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let err = with_metric!(
QUANTITY_MAP,
id,
metric,
test_get_errors!(metric, ping_name)
);
pub extern "C" fn fog_quantity_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
let err = with_metric!(QUANTITY_MAP, id, metric, test_get_errors!(metric));
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -34,11 +34,7 @@ pub unsafe extern "C" fn fog_rate_test_get_value(
}
#[no_mangle]
pub extern "C" fn fog_rate_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let err = with_metric!(RATE_MAP, id, metric, test_get_errors!(metric, ping_name));
pub extern "C" fn fog_rate_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
let err = with_metric!(RATE_MAP, id, metric, test_get_errors!(metric));
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -27,11 +27,7 @@ pub extern "C" fn fog_string_set(id: u32, value: &nsACString) {
}
#[no_mangle]
pub extern "C" fn fog_string_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let err = with_metric!(STRING_MAP, id, metric, test_get_errors!(metric, ping_name));
pub extern "C" fn fog_string_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
let err = with_metric!(STRING_MAP, id, metric, test_get_errors!(metric));
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -36,16 +36,7 @@ pub extern "C" fn fog_string_list_set(id: u32, value: &ThinVec<nsCString>) {
}
#[no_mangle]
pub extern "C" fn fog_string_list_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let err = with_metric!(
STRING_LIST_MAP,
id,
metric,
test_get_errors!(metric, ping_name)
);
pub extern "C" fn fog_string_list_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
let err = with_metric!(STRING_LIST_MAP, id, metric, test_get_errors!(metric));
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -42,16 +42,7 @@ pub extern "C" fn fog_timespan_test_get_value(id: u32, ping_name: &nsACString) -
}
#[no_mangle]
pub extern "C" fn fog_timespan_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let err = with_metric!(
TIMESPAN_MAP,
id,
metric,
test_get_errors!(metric, ping_name)
);
pub extern "C" fn fog_timespan_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
let err = with_metric!(TIMESPAN_MAP, id, metric, test_get_errors!(metric));
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -77,14 +77,14 @@ pub extern "C" fn fog_timing_distribution_test_get_value(
#[no_mangle]
pub extern "C" fn fog_timing_distribution_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let err = with_metric!(
TIMING_DISTRIBUTION_MAP,
id,
metric,
test_get_errors!(metric, ping_name)
test_get_errors!(metric)
);
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -23,11 +23,7 @@ pub extern "C" fn fog_url_set(id: u32, value: &nsACString) {
}
#[no_mangle]
pub extern "C" fn fog_url_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let err = with_metric!(URL_MAP, id, metric, test_get_errors!(metric, ping_name));
pub extern "C" fn fog_url_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
let err = with_metric!(URL_MAP, id, metric, test_get_errors!(metric));
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -31,11 +31,7 @@ pub extern "C" fn fog_uuid_generate_and_set(id: u32) {
}
#[no_mangle]
pub extern "C" fn fog_uuid_test_get_error(
id: u32,
ping_name: &nsACString,
error_str: &mut nsACString,
) -> bool {
let err = with_metric!(UUID_MAP, id, metric, test_get_errors!(metric, ping_name));
pub extern "C" fn fog_uuid_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
let err = with_metric!(UUID_MAP, id, metric, test_get_errors!(metric));
err.map(|err_str| error_str.assign(&err_str)).is_some()
}

View File

@ -96,14 +96,9 @@ impl Boolean for BooleanMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: glean::ErrorType,
ping_name: S,
) -> i32 {
let ping_name = ping_name.into().map(|s| s.to_string());
pub fn test_get_num_recorded_errors(&self, error: glean::ErrorType) -> i32 {
match self {
BooleanMetric::Parent(p) => p.test_get_num_recorded_errors(error, ping_name),
BooleanMetric::Parent(p) => p.test_get_num_recorded_errors(error),
BooleanMetric::Child(_) => panic!(
"Cannot get the number of recorded errors for boolean metric in non-parent process!"
),

View File

@ -119,16 +119,9 @@ impl Counter for CounterMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: glean::ErrorType,
ping_name: S,
) -> i32 {
let ping_name = ping_name.into().map(|s| s.to_string());
pub fn test_get_num_recorded_errors(&self, error: glean::ErrorType) -> i32 {
match self {
CounterMetric::Parent { inner, .. } => {
inner.test_get_num_recorded_errors(error, ping_name)
}
CounterMetric::Parent { inner, .. } => inner.test_get_num_recorded_errors(error),
CounterMetric::Child(c) => panic!(
"Cannot get the number of recorded errors for {:?} in non-parent process!",
c.0

View File

@ -105,15 +105,10 @@ impl CustomDistribution for CustomDistributionMetric {
}
}
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32 {
let ping_name = ping_name.into().map(|s| s.to_string());
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
match self {
CustomDistributionMetric::Parent { inner, .. } => {
inner.test_get_num_recorded_errors(error, ping_name)
inner.test_get_num_recorded_errors(error)
}
CustomDistributionMetric::Child(c) => panic!(
"Cannot get number of recorded errors for {:?} in non-parent process!",

View File

@ -158,14 +158,9 @@ impl Datetime for DatetimeMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: glean::ErrorType,
ping_name: S,
) -> i32 {
let ping_name = ping_name.into().map(|s| s.to_string());
pub fn test_get_num_recorded_errors(&self, error: glean::ErrorType) -> i32 {
match self {
DatetimeMetric::Parent(p) => p.test_get_num_recorded_errors(error, ping_name),
DatetimeMetric::Parent(p) => p.test_get_num_recorded_errors(error),
DatetimeMetric::Child(_) => panic!("Cannot get the number of recorded errors for DatetimeMetric in non-parent process!"),
}
}

View File

@ -90,16 +90,9 @@ impl Counter for DenominatorMetric {
}
}
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: glean::ErrorType,
ping_name: S,
) -> i32 {
let ping_name = ping_name.into().map(|s| s.to_string());
pub fn test_get_num_recorded_errors(&self, error: glean::ErrorType) -> i32 {
match self {
DenominatorMetric::Parent { inner, .. } => {
inner.test_get_num_recorded_errors(error, ping_name)
}
DenominatorMetric::Parent { inner, .. } => inner.test_get_num_recorded_errors(error),
DenominatorMetric::Child(c) => {
panic!(
"Cannot get the number of recorded errors for {:?} in non-parent process!",

View File

@ -112,15 +112,9 @@ impl<K: 'static + ExtraKeys + Send + Sync> Event for EventMetric<K> {
}
}
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: glean::ErrorType,
ping_name: S,
) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: glean::ErrorType) -> i32 {
match self {
EventMetric::Parent { inner, .. } => {
inner.test_get_num_recorded_errors(error, ping_name)
}
EventMetric::Parent { inner, .. } => inner.test_get_num_recorded_errors(error),
EventMetric::Child(c) => panic!(
"Cannot get the number of recorded errors for {:?} in non-parent process!",
c.0

View File

@ -175,16 +175,11 @@ where
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: ErrorType,
ping_name: S,
) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
if need_ipc() {
panic!("Use of labeled metrics in IPC land not yet implemented!");
} else {
let ping_name = ping_name.into().map(|s| s.to_string());
self.core.test_get_num_recorded_errors(error, ping_name)
self.core.test_get_num_recorded_errors(error)
}
}
}
@ -317,7 +312,7 @@ mod test {
assert_eq!(
1,
metric.test_get_num_recorded_errors(ErrorType::InvalidLabel, None)
metric.test_get_num_recorded_errors(ErrorType::InvalidLabel)
);
}
@ -355,7 +350,7 @@ mod test {
assert_eq!(
0,
metric.test_get_num_recorded_errors(ErrorType::InvalidLabel, None)
metric.test_get_num_recorded_errors(ErrorType::InvalidLabel)
);
}
}

View File

@ -107,13 +107,9 @@ impl Counter for LabeledCounterMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: glean::ErrorType,
ping_name: S,
) -> i32 {
pub fn test_get_num_recorded_errors(&self, error: glean::ErrorType) -> i32 {
match self {
LabeledCounterMetric::Parent(p) => p.test_get_num_recorded_errors(error, ping_name),
LabeledCounterMetric::Parent(p) => p.test_get_num_recorded_errors(error),
LabeledCounterMetric::Child { id, .. } => panic!(
"Cannot get the number of recorded errors for {:?} in non-parent process!",
id

View File

@ -125,15 +125,10 @@ impl MemoryDistribution for MemoryDistributionMetric {
/// # Returns
///
/// The number of errors recorded.
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: glean::ErrorType,
ping_name: S,
) -> i32 {
let ping_name = ping_name.into().map(|s| s.to_string());
pub fn test_get_num_recorded_errors(&self, error: glean::ErrorType) -> i32 {
match self {
MemoryDistributionMetric::Parent { inner, .. } => {
inner.test_get_num_recorded_errors(error, ping_name)
inner.test_get_num_recorded_errors(error)
}
MemoryDistributionMetric::Child(c) => panic!(
"Cannot get the number of recorded errors for {:?} in non-parent process!",

View File

@ -88,16 +88,9 @@ impl Numerator for NumeratorMetric {
}
}
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: glean::ErrorType,
ping_name: S,
) -> i32 {
let ping_name = ping_name.into().map(|s| s.to_string());
pub fn test_get_num_recorded_errors(&self, error: glean::ErrorType) -> i32 {
match self {
NumeratorMetric::Parent { inner, .. } => {
inner.test_get_num_recorded_errors(error, ping_name)
}
NumeratorMetric::Parent { inner, .. } => inner.test_get_num_recorded_errors(error),
NumeratorMetric::Child(c) => {
panic!(
"Cannot get the number of recorded errors for {:?} in non-parent process!",

View File

@ -99,15 +99,10 @@ impl Quantity for QuantityMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: glean::ErrorType,
ping_name: S,
) -> i32 {
let ping_name = ping_name.into().map(|s| s.to_string());
pub fn test_get_num_recorded_errors(&self, error: glean::ErrorType) -> i32 {
match self {
QuantityMetric::Parent(p) => {
p.test_get_num_recorded_errors(error, ping_name)
p.test_get_num_recorded_errors(error)
}
QuantityMetric::Child(_) => panic!(
"Cannot get the number of recorded errors for quantity metric in non-parent process!"

View File

@ -107,16 +107,9 @@ impl Rate for RateMetric {
}
}
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: glean::ErrorType,
ping_name: S,
) -> i32 {
let ping_name = ping_name.into().map(|s| s.to_string());
pub fn test_get_num_recorded_errors(&self, error: glean::ErrorType) -> i32 {
match self {
RateMetric::Parent { inner, .. } => {
inner.test_get_num_recorded_errors(error, ping_name)
}
RateMetric::Parent { inner, .. } => inner.test_get_num_recorded_errors(error),
RateMetric::Child(c) => {
panic!(
"Cannot get the number of recorded errors for {:?} in non-parent process!",

View File

@ -123,14 +123,9 @@ impl glean::traits::String for StringMetric {
/// # Returns
///
/// The number of errors reported.
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: glean::ErrorType,
ping_name: S,
) -> i32 {
let ping_name = ping_name.into().map(|s| s.to_string());
pub fn test_get_num_recorded_errors(&self, error: glean::ErrorType) -> i32 {
match self {
StringMetric::Parent(p) => p.test_get_num_recorded_errors(error, ping_name),
StringMetric::Parent(p) => p.test_get_num_recorded_errors(error),
StringMetric::Child(_) => panic!(
"Cannot get the number of recorded errors for string metric in non-parent process!"
),

View File

@ -143,16 +143,9 @@ impl StringList for StringListMetric {
/// # Returns
///
/// The number of errors recorded.
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: glean::ErrorType,
ping_name: S,
) -> i32 {
let ping_name = ping_name.into().map(|s| s.to_string());
pub fn test_get_num_recorded_errors(&self, error: glean::ErrorType) -> i32 {
match self {
StringListMetric::Parent { inner, .. } => {
inner.test_get_num_recorded_errors(error, ping_name)
}
StringListMetric::Parent { inner, .. } => inner.test_get_num_recorded_errors(error),
StringListMetric::Child(c) => panic!(
"Cannot get the number of recorded errors for {:?} in non-parent process!",
c.0

View File

@ -105,14 +105,9 @@ impl Timespan for TimespanMetric {
}
}
pub fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
&self,
error: glean::ErrorType,
ping_name: S,
) -> i32 {
let ping_name = ping_name.into().map(|s| s.to_string());
pub fn test_get_num_recorded_errors(&self, error: glean::ErrorType) -> i32 {
match self {
TimespanMetric::Parent(p, _) => p.test_get_num_recorded_errors(error, ping_name),
TimespanMetric::Parent(p, _) => p.test_get_num_recorded_errors(error),
TimespanMetric::Child => {
panic!("Cannot get the number of recorded errors for timespan metric in non-parent process!");
}

Some files were not shown because too many files have changed in this diff Show More