forked from mirrors/gecko-dev
Bug 1895786 - Vendor Glean SDK v60.1.0 r=TravisLong,supply-chain-reviewers,mach-reviewers,android-reviewers,Roger
The biggest thing for m-c is the addition of a single-duration API for timing_distribution that was previously papered over in the FOG-specific impl using the SDK's multi-duration API. This ought to drop unnecessary `vec![]`-caused allocations for some fairly- high-frequency calls to AccumulateRawDuration. Differential Revision: https://phabricator.services.mozilla.com/D209864
This commit is contained in:
parent
1ea6f31ea0
commit
9f4b4ab30a
23 changed files with 236 additions and 234 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
|
@ -2387,9 +2387,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "glean"
|
||||
version = "60.0.0"
|
||||
version = "60.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "782325c56864d3ce57e46840b8eb9318e8d85f5b80ba88fb85bb05d47e2e119b"
|
||||
checksum = "17dbdd29dcae47b7f8fae9378ae7bf17be18b902cbb490341af2f4d04ead6bbf"
|
||||
dependencies = [
|
||||
"glean-core",
|
||||
"inherent",
|
||||
|
|
@ -2400,9 +2400,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "glean-core"
|
||||
version = "60.0.0"
|
||||
version = "60.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1d6ca4a985a5d5a947334338381da0b8a24cf23e8da574c1d40e74067c91b81"
|
||||
checksum = "99bf32010135ab5b1db37fff66096d08b9df4e9dd94c881aa0774df61c122fdf"
|
||||
dependencies = [
|
||||
"android_logger",
|
||||
"bincode",
|
||||
|
|
|
|||
8
gfx/wr/Cargo.lock
generated
8
gfx/wr/Cargo.lock
generated
|
|
@ -996,9 +996,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "glean"
|
||||
version = "60.0.0"
|
||||
version = "60.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "782325c56864d3ce57e46840b8eb9318e8d85f5b80ba88fb85bb05d47e2e119b"
|
||||
checksum = "17dbdd29dcae47b7f8fae9378ae7bf17be18b902cbb490341af2f4d04ead6bbf"
|
||||
dependencies = [
|
||||
"glean-core",
|
||||
"inherent",
|
||||
|
|
@ -1009,9 +1009,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "glean-core"
|
||||
version = "60.0.0"
|
||||
version = "60.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1d6ca4a985a5d5a947334338381da0b8a24cf23e8da574c1d40e74067c91b81"
|
||||
checksum = "99bf32010135ab5b1db37fff66096d08b9df4e9dd94c881aa0774df61c122fdf"
|
||||
dependencies = [
|
||||
"android_logger",
|
||||
"bincode",
|
||||
|
|
|
|||
|
|
@ -52,7 +52,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 = { version = "60.0.0", optional = true }
|
||||
glean = { version = "60.1.0", optional = true }
|
||||
firefox-on-glean = { version = "0.1.0", optional = true }
|
||||
swgl = { path = "../swgl", optional = true }
|
||||
topological-sort = "0.1"
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ tracy-rs = "0.1.2"
|
|||
log = "0.4"
|
||||
lazy_static = "1"
|
||||
fxhash = "0.2.1"
|
||||
glean = { version = "60.0.0", optional = true }
|
||||
glean = { version = "60.1.0", optional = true }
|
||||
firefox-on-glean = { version = "0.1.0", optional = true }
|
||||
serde = { optional = true, version = "1.0", features = ["serde_derive"] }
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ object Versions {
|
|||
const val serialization = "1.6.3"
|
||||
const val python_envs_plugin = "0.0.31"
|
||||
|
||||
const val mozilla_glean = "60.0.0"
|
||||
const val mozilla_glean = "60.1.0"
|
||||
|
||||
const val junit = "4.13.2"
|
||||
const val robolectric = "4.12.1"
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ vendored:third_party/python/wheel
|
|||
vendored:third_party/python/zipp
|
||||
# glean-sdk may not be installable if a wheel isn't available
|
||||
# and it has to be built from source.
|
||||
pypi-optional:glean-sdk==60.0.0:telemetry will not be collected
|
||||
pypi-optional:glean-sdk==60.1.0: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).
|
||||
|
|
|
|||
|
|
@ -279,10 +279,6 @@ criteria = "safe-to-deploy"
|
|||
version = "1.3.3"
|
||||
criteria = "safe-to-deploy"
|
||||
|
||||
[[exemptions.bitflags]]
|
||||
version = "1.3.2"
|
||||
criteria = "safe-to-deploy"
|
||||
|
||||
[[exemptions.bitreader]]
|
||||
version = "0.3.6"
|
||||
criteria = "safe-to-deploy"
|
||||
|
|
@ -616,10 +612,6 @@ criteria = "safe-to-deploy"
|
|||
version = "0.2.7"
|
||||
criteria = "safe-to-deploy"
|
||||
|
||||
[[exemptions.objc_exception]]
|
||||
version = "0.1.2"
|
||||
criteria = "safe-to-deploy"
|
||||
|
||||
[[exemptions.object]]
|
||||
version = "0.28.4"
|
||||
criteria = "safe-to-deploy"
|
||||
|
|
@ -628,6 +620,10 @@ criteria = "safe-to-deploy"
|
|||
version = "1.12.0"
|
||||
criteria = "safe-to-deploy"
|
||||
|
||||
[[exemptions.owning_ref]]
|
||||
version = "0.4.1"
|
||||
criteria = "safe-to-deploy"
|
||||
|
||||
[[exemptions.packed_simd]]
|
||||
version = "0.3.8"
|
||||
criteria = "safe-to-deploy"
|
||||
|
|
|
|||
|
|
@ -64,13 +64,6 @@ user-id = 696
|
|||
user-login = "fitzgen"
|
||||
user-name = "Nick Fitzgerald"
|
||||
|
||||
[[publisher.byteorder]]
|
||||
version = "1.4.3"
|
||||
when = "2021-03-10"
|
||||
user-id = 189
|
||||
user-login = "BurntSushi"
|
||||
user-name = "Andrew Gallant"
|
||||
|
||||
[[publisher.byteorder]]
|
||||
version = "1.5.0"
|
||||
when = "2023-10-06"
|
||||
|
|
@ -134,13 +127,6 @@ user-id = 5946
|
|||
user-login = "jrmuizel"
|
||||
user-name = "Jeff Muizelaar"
|
||||
|
||||
[[publisher.core-foundation-sys]]
|
||||
version = "0.8.3"
|
||||
when = "2021-10-12"
|
||||
user-id = 2396
|
||||
user-login = "jdm"
|
||||
user-name = "Josh Matthews"
|
||||
|
||||
[[publisher.core-foundation-sys]]
|
||||
version = "0.8.4"
|
||||
when = "2023-04-03"
|
||||
|
|
@ -190,13 +176,6 @@ user-id = 3618
|
|||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.encoding_rs]]
|
||||
version = "0.8.33"
|
||||
when = "2023-08-23"
|
||||
user-id = 4484
|
||||
user-login = "hsivonen"
|
||||
user-name = "Henri Sivonen"
|
||||
|
||||
[[publisher.encoding_rs]]
|
||||
version = "0.8.34"
|
||||
when = "2024-04-10"
|
||||
|
|
@ -247,15 +226,15 @@ user-login = "jrmuizel"
|
|||
user-name = "Jeff Muizelaar"
|
||||
|
||||
[[publisher.glean]]
|
||||
version = "60.0.0"
|
||||
when = "2024-04-22"
|
||||
version = "60.1.0"
|
||||
when = "2024-05-06"
|
||||
user-id = 48
|
||||
user-login = "badboy"
|
||||
user-name = "Jan-Erik Rediger"
|
||||
|
||||
[[publisher.glean-core]]
|
||||
version = "60.0.0"
|
||||
when = "2024-04-22"
|
||||
version = "60.1.0"
|
||||
when = "2024-05-06"
|
||||
user-id = 48
|
||||
user-login = "badboy"
|
||||
user-name = "Jan-Erik Rediger"
|
||||
|
|
@ -274,13 +253,6 @@ user-id = 359
|
|||
user-login = "seanmonstar"
|
||||
user-name = "Sean McArthur"
|
||||
|
||||
[[publisher.hashbrown]]
|
||||
version = "0.14.3"
|
||||
when = "2023-11-26"
|
||||
user-id = 2915
|
||||
user-login = "Amanieu"
|
||||
user-name = "Amanieu d'Antras"
|
||||
|
||||
[[publisher.hashbrown]]
|
||||
version = "0.14.5"
|
||||
when = "2024-04-28"
|
||||
|
|
@ -302,13 +274,6 @@ user-id = 359
|
|||
user-login = "seanmonstar"
|
||||
user-name = "Sean McArthur"
|
||||
|
||||
[[publisher.indexmap]]
|
||||
version = "1.9.3"
|
||||
when = "2023-03-24"
|
||||
user-id = 539
|
||||
user-login = "cuviper"
|
||||
user-name = "Josh Stone"
|
||||
|
||||
[[publisher.indexmap]]
|
||||
version = "2.2.6"
|
||||
when = "2024-03-23"
|
||||
|
|
@ -344,13 +309,6 @@ user-id = 1
|
|||
user-login = "alexcrichton"
|
||||
user-name = "Alex Crichton"
|
||||
|
||||
[[publisher.libc]]
|
||||
version = "0.2.152"
|
||||
when = "2024-01-07"
|
||||
user-id = 51017
|
||||
user-login = "JohnTitor"
|
||||
user-name = "Yuki Okushi"
|
||||
|
||||
[[publisher.libc]]
|
||||
version = "0.2.153"
|
||||
when = "2024-01-31"
|
||||
|
|
@ -455,12 +413,6 @@ when = "2022-10-16"
|
|||
user-id = 52553
|
||||
user-login = "embark-studios"
|
||||
|
||||
[[publisher.prio]]
|
||||
version = "0.15.3"
|
||||
when = "2023-10-03"
|
||||
user-id = 213776
|
||||
user-login = "divviup-github-automation"
|
||||
|
||||
[[publisher.prio]]
|
||||
version = "0.16.2"
|
||||
when = "2024-03-19"
|
||||
|
|
@ -544,13 +496,6 @@ user-id = 2915
|
|||
user-login = "Amanieu"
|
||||
user-name = "Amanieu d'Antras"
|
||||
|
||||
[[publisher.serde]]
|
||||
version = "1.0.197"
|
||||
when = "2024-02-20"
|
||||
user-id = 3618
|
||||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.serde]]
|
||||
version = "1.0.198"
|
||||
when = "2024-04-16"
|
||||
|
|
@ -565,13 +510,6 @@ user-id = 3618
|
|||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.serde_derive]]
|
||||
version = "1.0.197"
|
||||
when = "2024-02-20"
|
||||
user-id = 3618
|
||||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.serde_derive]]
|
||||
version = "1.0.198"
|
||||
when = "2024-04-16"
|
||||
|
|
@ -579,13 +517,6 @@ user-id = 3618
|
|||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.serde_json]]
|
||||
version = "1.0.93"
|
||||
when = "2023-02-08"
|
||||
user-id = 3618
|
||||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.serde_json]]
|
||||
version = "1.0.116"
|
||||
when = "2024-04-16"
|
||||
|
|
@ -628,13 +559,6 @@ user-id = 189
|
|||
user-login = "BurntSushi"
|
||||
user-name = "Andrew Gallant"
|
||||
|
||||
[[publisher.thiserror]]
|
||||
version = "1.0.57"
|
||||
when = "2024-02-11"
|
||||
user-id = 3618
|
||||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.thiserror]]
|
||||
version = "1.0.59"
|
||||
when = "2024-04-20"
|
||||
|
|
@ -642,13 +566,6 @@ user-id = 3618
|
|||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.thiserror-impl]]
|
||||
version = "1.0.57"
|
||||
when = "2024-02-11"
|
||||
user-id = 3618
|
||||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.thiserror-impl]]
|
||||
version = "1.0.59"
|
||||
when = "2024-04-20"
|
||||
|
|
@ -933,25 +850,6 @@ criteria = "safe-to-deploy"
|
|||
version = "0.21.0"
|
||||
notes = "This crate has no dependencies, no build.rs, and contains no unsafe code."
|
||||
|
||||
[[audits.bytecode-alliance.audits.bitflags]]
|
||||
who = "Jamey Sharp <jsharp@fastly.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "2.1.0 -> 2.2.1"
|
||||
notes = """
|
||||
This version adds unsafe impls of traits from the bytemuck crate when built
|
||||
with that library enabled, but I believe the impls satisfy the documented
|
||||
safety requirements for bytemuck. The other changes are minor.
|
||||
"""
|
||||
|
||||
[[audits.bytecode-alliance.audits.bitflags]]
|
||||
who = "Alex Crichton <alex@alexcrichton.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "2.3.2 -> 2.3.3"
|
||||
notes = """
|
||||
Nothing outside the realm of what one would expect from a bitflags generator,
|
||||
all as expected.
|
||||
"""
|
||||
|
||||
[[audits.bytecode-alliance.audits.block-buffer]]
|
||||
who = "Benjamin Bouvier <public@benj.me>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
|
@ -1691,13 +1589,6 @@ version = "0.1.2"
|
|||
notes = "TOML parser, forked from toml 0.5"
|
||||
aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml"
|
||||
|
||||
[[audits.mozilla.audits.bitflags]]
|
||||
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "2.4.0 -> 2.4.1"
|
||||
notes = "Only allowing new clippy lints"
|
||||
aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml"
|
||||
|
||||
[[audits.mozilla.audits.either]]
|
||||
who = "Nika Layzell <nika@thelayzells.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
|
@ -1708,13 +1599,6 @@ no unsafe code.
|
|||
"""
|
||||
aggregated-from = "https://raw.githubusercontent.com/mozilla/cargo-vet/main/supply-chain/audits.toml"
|
||||
|
||||
[[audits.mozilla.audits.goblin]]
|
||||
who = "Alex Franchuk <afranchuk@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.7.1 -> 0.8.0"
|
||||
notes = "Fairly straightforward feature improvements."
|
||||
aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml"
|
||||
|
||||
[[audits.mozilla.audits.lazy_static]]
|
||||
who = "Nika Layzell <nika@thelayzells.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
2
third_party/rust/glean-core/Cargo.toml
vendored
2
third_party/rust/glean-core/Cargo.toml
vendored
|
|
@ -13,7 +13,7 @@
|
|||
edition = "2021"
|
||||
rust-version = "1.66"
|
||||
name = "glean-core"
|
||||
version = "60.0.0"
|
||||
version = "60.1.0"
|
||||
authors = [
|
||||
"Jan-Erik Rediger <jrediger@mozilla.com>",
|
||||
"The Glean Team <glean-team@mozilla.com>",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use std::io::BufRead;
|
|||
use std::io::BufReader;
|
||||
use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::RwLock;
|
||||
use std::sync::{Mutex, RwLock};
|
||||
|
||||
use chrono::{DateTime, FixedOffset, Utc};
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ pub struct EventDatabase {
|
|||
/// The in-memory list of events
|
||||
event_stores: RwLock<HashMap<String, Vec<StoredEvent>>>,
|
||||
/// A lock to be held when doing operations on the filesystem
|
||||
file_lock: RwLock<()>,
|
||||
file_lock: Mutex<()>,
|
||||
}
|
||||
|
||||
impl EventDatabase {
|
||||
|
|
@ -113,7 +113,7 @@ impl EventDatabase {
|
|||
Ok(Self {
|
||||
path,
|
||||
event_stores: RwLock::new(HashMap::new()),
|
||||
file_lock: RwLock::new(()),
|
||||
file_lock: Mutex::new(()),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ impl EventDatabase {
|
|||
// a lock on `event_stores`.
|
||||
// This is a potential lock-order-inversion.
|
||||
let mut db = self.event_stores.write().unwrap(); // safe unwrap, only error case is poisoning
|
||||
let _lock = self.file_lock.write().unwrap(); // safe unwrap, only error case is poisoning
|
||||
let _lock = self.file_lock.lock().unwrap(); // safe unwrap, only error case is poisoning
|
||||
|
||||
for entry in fs::read_dir(&self.path)? {
|
||||
let entry = entry?;
|
||||
|
|
@ -326,7 +326,7 @@ impl EventDatabase {
|
|||
/// * `store_name` - The name of the store.
|
||||
/// * `event_json` - The event content, as a single-line JSON-encoded string.
|
||||
fn write_event_to_disk(&self, store_name: &str, event_json: &str) {
|
||||
let _lock = self.file_lock.write().unwrap(); // safe unwrap, only error case is poisoning
|
||||
let _lock = self.file_lock.lock().unwrap(); // safe unwrap, only error case is poisoning
|
||||
if let Err(err) = OpenOptions::new()
|
||||
.create(true)
|
||||
.append(true)
|
||||
|
|
@ -576,7 +576,7 @@ impl EventDatabase {
|
|||
.unwrap() // safe unwrap, only error case is poisoning
|
||||
.remove(&store_name.to_string());
|
||||
|
||||
let _lock = self.file_lock.write().unwrap(); // safe unwrap, only error case is poisoning
|
||||
let _lock = self.file_lock.lock().unwrap(); // safe unwrap, only error case is poisoning
|
||||
if let Err(err) = fs::remove_file(self.path.join(store_name)) {
|
||||
match err.kind() {
|
||||
std::io::ErrorKind::NotFound => {
|
||||
|
|
@ -596,7 +596,7 @@ impl EventDatabase {
|
|||
self.event_stores.write().unwrap().clear();
|
||||
|
||||
// safe unwrap, only error case is poisoning
|
||||
let _lock = self.file_lock.write().unwrap();
|
||||
let _lock = self.file_lock.lock().unwrap();
|
||||
std::fs::remove_dir_all(&self.path)?;
|
||||
create_dir_all(&self.path)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -195,12 +195,12 @@ mod test {
|
|||
fn accumulate_large_numbers() {
|
||||
let mut hist = Histogram::exponential(1, 500, 10);
|
||||
|
||||
hist.accumulate(u64::max_value());
|
||||
hist.accumulate(u64::max_value());
|
||||
hist.accumulate(u64::MAX);
|
||||
hist.accumulate(u64::MAX);
|
||||
|
||||
assert_eq!(2, hist.count());
|
||||
// Saturate before overflowing
|
||||
assert_eq!(u64::max_value(), hist.sum());
|
||||
assert_eq!(u64::MAX, hist.sum());
|
||||
assert_eq!(2, hist.values[&500]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,12 +167,12 @@ mod test {
|
|||
fn accumulate_large_numbers() {
|
||||
let mut hist = Histogram::linear(1, 500, 10);
|
||||
|
||||
hist.accumulate(u64::max_value());
|
||||
hist.accumulate(u64::max_value());
|
||||
hist.accumulate(u64::MAX);
|
||||
hist.accumulate(u64::MAX);
|
||||
|
||||
assert_eq!(2, hist.count());
|
||||
// Saturate before overflowing
|
||||
assert_eq!(u64::max_value(), hist.sum());
|
||||
assert_eq!(u64::MAX, hist.sum());
|
||||
assert_eq!(2, hist.values[&500]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
use std::collections::HashMap;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::common_metric_data::CommonMetricDataInternal;
|
||||
use crate::error_recording::{record_error, test_get_num_recorded_errors, ErrorType};
|
||||
|
|
@ -412,6 +413,35 @@ impl TimingDistributionMetric {
|
|||
})
|
||||
}
|
||||
|
||||
/// Accumulates precisely one duration to the metric.
|
||||
///
|
||||
/// Like `TimingDistribution::accumulate_single_sample`, but for use when the
|
||||
/// duration is:
|
||||
///
|
||||
/// * measured externally, or
|
||||
/// * is in a unit different from the timing_distribution's internal TimeUnit.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `duration` - The single duration to be recorded in the metric.
|
||||
///
|
||||
/// ## Notes
|
||||
///
|
||||
/// Reports an [`ErrorType::InvalidOverflow`] error if `duration` is longer than
|
||||
/// `MAX_SAMPLE_TIME`.
|
||||
///
|
||||
/// The API client is responsible for ensuring that `duration` is derived from a
|
||||
/// monotonic clock source that behaves consistently over computer sleep across
|
||||
/// the application's platforms. Otherwise the resulting data may not share the same
|
||||
/// guarantees that other `timing_distribution` metrics' data do.
|
||||
pub fn accumulate_raw_duration(&self, duration: Duration) {
|
||||
let duration_ns = duration.as_nanos().try_into().unwrap_or(u64::MAX);
|
||||
let metric = self.clone();
|
||||
crate::launch_with_glean(move |glean| {
|
||||
metric.accumulate_raw_samples_nanos_sync(glean, &[duration_ns])
|
||||
})
|
||||
}
|
||||
|
||||
/// **Test-only API (exported for testing purposes).**
|
||||
///
|
||||
/// Accumulates the provided samples in the metric.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ use crate::metrics::DistributionData;
|
|||
use crate::metrics::TimerId;
|
||||
use crate::ErrorType;
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
/// A description for the [`TimingDistributionMetric`](crate::metrics::TimingDistributionMetric) type.
|
||||
///
|
||||
/// When changing this trait, make sure all the operations are
|
||||
|
|
@ -103,6 +105,29 @@ pub trait TimingDistribution {
|
|||
/// are longer than `MAX_SAMPLE_TIME`.
|
||||
fn accumulate_raw_samples_nanos(&self, samples: Vec<u64>);
|
||||
|
||||
/// Accumulates precisely one duration to the metric.
|
||||
///
|
||||
/// Like `TimingDistribution::accumulate_single_sample`, but for use when the
|
||||
/// duration is:
|
||||
///
|
||||
/// * measured externally, or
|
||||
/// * is in a unit different from the timing_distribution's internal TimeUnit.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `duration` - The single duration to be recorded in the metric.
|
||||
///
|
||||
/// ## Notes
|
||||
///
|
||||
/// Reports an [`ErrorType::InvalidOverflow`] error if `duration` is longer than
|
||||
/// `MAX_SAMPLE_TIME`.
|
||||
///
|
||||
/// The API client is responsible for ensuring that `duration` is derived from a
|
||||
/// monotonic clock source that behaves consistently over computer sleep across
|
||||
/// the application's platforms. Otherwise the resulting data may not share the same
|
||||
/// guarantees that other `timing_distribution` metrics' data do.
|
||||
fn accumulate_raw_duration(&self, duration: Duration);
|
||||
|
||||
/// **Exported for test purposes.**
|
||||
///
|
||||
/// Gets the currently stored value of the metric.
|
||||
|
|
|
|||
7
third_party/rust/glean-core/tests/counter.rs
vendored
7
third_party/rust/glean-core/tests/counter.rs
vendored
|
|
@ -168,10 +168,7 @@ fn saturates_at_boundary() {
|
|||
});
|
||||
|
||||
counter.add_sync(&glean, 2);
|
||||
counter.add_sync(&glean, i32::max_value());
|
||||
counter.add_sync(&glean, i32::MAX);
|
||||
|
||||
assert_eq!(
|
||||
i32::max_value(),
|
||||
counter.get_value(&glean, Some("store1")).unwrap()
|
||||
);
|
||||
assert_eq!(i32::MAX, counter.get_value(&glean, Some("store1")).unwrap());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ fn large_nanoseconds_values() {
|
|||
);
|
||||
|
||||
let time = Duration::from_secs(10).as_nanos() as u64;
|
||||
assert!(time > u64::from(u32::max_value()));
|
||||
assert!(time > u64::from(u32::MAX));
|
||||
|
||||
let id = 4u64.into();
|
||||
metric.set_start(id, 0);
|
||||
|
|
|
|||
2
third_party/rust/glean/.cargo-checksum.json
vendored
2
third_party/rust/glean/.cargo-checksum.json
vendored
|
|
@ -1 +1 @@
|
|||
{"files":{"Cargo.toml":"e13e9991a07e8b9b60f2be6642b3c3b046d1a93665eb5862190412cac1f2fea4","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5627cc81e6187ab6c2b4dff061af16d559edcab64ba786bac39daa69c703c595","src/common_test.rs":"de47b53dcca37985c0a2b8c02daecbf32309aa54f5a4dd9290719c2c1fd0fa55","src/configuration.rs":"27075b12236021c54d0c99427bcbd417933ca02545275604d3c13f32ca25af13","src/core_metrics.rs":"fef8fb4e5fa57c179836c6eb2cf59278fe3b8b036dbe57b0ff02971b4acd822f","src/lib.rs":"3a43c992275f06c4189ffc9ca0775fe840b5598c2f6a39504aea3ae5df43fa23","src/net/http_uploader.rs":"01ad5bd91384411a12c74434cd1c5cd585078cb34faba4615c70bdb669a9bccb","src/net/mod.rs":"f47b96bb878f1a6c771cedbaeaeefb270bc87fb1d1bbbed1b282dddca16216ed","src/private/event.rs":"d7c70c02648584c19c73af89e5180d3c6153c911f2c6830f7d1599b18d6150eb","src/private/mod.rs":"3565eb569d2b96f938f130abe0fc3ee3f55e7e03fd6501e309d3ef6af72ef6ee","src/private/object.rs":"3f70363a196aea46cc163af025a53e48c117c6208babc4bce772bb4c337cced8","src/private/ping.rs":"31d33d7f661a7a17ccb69351328700b4d7b80024d1e128f406c3534f9d163475","src/system.rs":"6eae5b41c15eba9cad6dbd116abe3519ee3e1fe034e79bdd692b029829a8c384","src/test.rs":"39dd7468dcdaf17593b8b07970ced25c07cbd76853aaef2532fdcad0281a21d3","tests/common/mod.rs":"08fb9483d9b6ed9fe873b4395245166ae8a15263be750c7a8e298c41d9604745","tests/init_fails.rs":"46d7064bba9386c3065635434e17ac9212c6c2236b3cd12bd985fc3229e659a3","tests/never_init.rs":"7a6e8a011fbd945f2544f204367eeceff3f6039c99d98799477e3b2352ae6227","tests/no_time_to_init.rs":"4a5bdddc2f8226d2ad17038229e8767a6dd195977af49527fbb84a9f6b0154bb","tests/overflowing_preinit.rs":"7ad4b2274dd9240b53430859a4eb1d2597cf508a5a678333f3d3abbadd2ed4a7","tests/persist_ping_lifetime.rs":"81415dc1d74743f02269f0d0dfa524003147056853f080276972e64a0b761d3c","tests/persist_ping_lifetime_nopanic.rs":"18379d3ffbf4a2c8c684c04ff7a0660b86dfbbb447db2d24dfed6073cb7ddf8f","tests/schema.rs":"dde65bce8a715ca3bd9c54b2466d831dd5e0d559e0773fe7657827f22a66bb44","tests/simple.rs":"1835b5df6f76ff894b45805bd54eaab23ca2d9d2b0694ec64af3aa6132baf30e","tests/test-shutdown-blocking.sh":"a44d8d4bbe2ee3ede9e48121150ae7a5386025160c5cef2181ca142232c5fb27","tests/test-thread-crashing.sh":"8d5ed070754e09fbe55183bb2792ae6e234a95770e39397caf05e4ec4d6015db","tests/upload_timing.rs":"6a97aa355d808123af0914ffecf1da0ecb2cc441c95c63c600b14f97ce0d45a0"},"package":"782325c56864d3ce57e46840b8eb9318e8d85f5b80ba88fb85bb05d47e2e119b"}
|
||||
{"files":{"Cargo.toml":"78a1972b9bbfcd28816592f60f1a504adcfd041936ce5d0fec3e0788391c784a","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5627cc81e6187ab6c2b4dff061af16d559edcab64ba786bac39daa69c703c595","src/common_test.rs":"de47b53dcca37985c0a2b8c02daecbf32309aa54f5a4dd9290719c2c1fd0fa55","src/configuration.rs":"27075b12236021c54d0c99427bcbd417933ca02545275604d3c13f32ca25af13","src/core_metrics.rs":"fef8fb4e5fa57c179836c6eb2cf59278fe3b8b036dbe57b0ff02971b4acd822f","src/lib.rs":"3a43c992275f06c4189ffc9ca0775fe840b5598c2f6a39504aea3ae5df43fa23","src/net/http_uploader.rs":"01ad5bd91384411a12c74434cd1c5cd585078cb34faba4615c70bdb669a9bccb","src/net/mod.rs":"f47b96bb878f1a6c771cedbaeaeefb270bc87fb1d1bbbed1b282dddca16216ed","src/private/event.rs":"d7c70c02648584c19c73af89e5180d3c6153c911f2c6830f7d1599b18d6150eb","src/private/mod.rs":"3565eb569d2b96f938f130abe0fc3ee3f55e7e03fd6501e309d3ef6af72ef6ee","src/private/object.rs":"3f70363a196aea46cc163af025a53e48c117c6208babc4bce772bb4c337cced8","src/private/ping.rs":"31d33d7f661a7a17ccb69351328700b4d7b80024d1e128f406c3534f9d163475","src/system.rs":"6eae5b41c15eba9cad6dbd116abe3519ee3e1fe034e79bdd692b029829a8c384","src/test.rs":"39dd7468dcdaf17593b8b07970ced25c07cbd76853aaef2532fdcad0281a21d3","tests/common/mod.rs":"08fb9483d9b6ed9fe873b4395245166ae8a15263be750c7a8e298c41d9604745","tests/init_fails.rs":"46d7064bba9386c3065635434e17ac9212c6c2236b3cd12bd985fc3229e659a3","tests/never_init.rs":"7a6e8a011fbd945f2544f204367eeceff3f6039c99d98799477e3b2352ae6227","tests/no_time_to_init.rs":"4a5bdddc2f8226d2ad17038229e8767a6dd195977af49527fbb84a9f6b0154bb","tests/overflowing_preinit.rs":"7ad4b2274dd9240b53430859a4eb1d2597cf508a5a678333f3d3abbadd2ed4a7","tests/persist_ping_lifetime.rs":"81415dc1d74743f02269f0d0dfa524003147056853f080276972e64a0b761d3c","tests/persist_ping_lifetime_nopanic.rs":"18379d3ffbf4a2c8c684c04ff7a0660b86dfbbb447db2d24dfed6073cb7ddf8f","tests/schema.rs":"dde65bce8a715ca3bd9c54b2466d831dd5e0d559e0773fe7657827f22a66bb44","tests/simple.rs":"1835b5df6f76ff894b45805bd54eaab23ca2d9d2b0694ec64af3aa6132baf30e","tests/test-shutdown-blocking.sh":"a44d8d4bbe2ee3ede9e48121150ae7a5386025160c5cef2181ca142232c5fb27","tests/test-thread-crashing.sh":"8d5ed070754e09fbe55183bb2792ae6e234a95770e39397caf05e4ec4d6015db","tests/timing_distribution_single_sample.rs":"fddf2f13f1620a8808029d250a64e4c822828bf80b4bb4f9e3b645ab70643f9b","tests/upload_timing.rs":"6a97aa355d808123af0914ffecf1da0ecb2cc441c95c63c600b14f97ce0d45a0"},"package":"17dbdd29dcae47b7f8fae9378ae7bf17be18b902cbb490341af2f4d04ead6bbf"}
|
||||
4
third_party/rust/glean/Cargo.toml
vendored
4
third_party/rust/glean/Cargo.toml
vendored
|
|
@ -13,7 +13,7 @@
|
|||
edition = "2021"
|
||||
rust-version = "1.66"
|
||||
name = "glean"
|
||||
version = "60.0.0"
|
||||
version = "60.1.0"
|
||||
authors = [
|
||||
"Jan-Erik Rediger <jrediger@mozilla.com>",
|
||||
"The Glean Team <glean-team@mozilla.com>",
|
||||
|
|
@ -35,7 +35,7 @@ license = "MPL-2.0"
|
|||
repository = "https://github.com/mozilla/glean"
|
||||
|
||||
[dependencies.glean-core]
|
||||
version = "60.0.0"
|
||||
version = "60.1.0"
|
||||
|
||||
[dependencies.inherent]
|
||||
version = "1"
|
||||
|
|
|
|||
70
third_party/rust/glean/tests/timing_distribution_single_sample.rs
vendored
Normal file
70
third_party/rust/glean/tests/timing_distribution_single_sample.rs
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
// 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 glean::{ConfigurationBuilder, ErrorType};
|
||||
use std::time::Duration;
|
||||
|
||||
/// A timing_distribution
|
||||
mod metrics {
|
||||
use glean::private::*;
|
||||
use glean::{Lifetime, TimeUnit};
|
||||
use glean_core::CommonMetricData;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
pub static boo: Lazy<TimingDistributionMetric> = Lazy::new(|| {
|
||||
TimingDistributionMetric::new(
|
||||
CommonMetricData {
|
||||
name: "boo".into(),
|
||||
category: "sample".into(),
|
||||
send_in_pings: vec!["validation".into()],
|
||||
lifetime: Lifetime::Ping,
|
||||
disabled: false,
|
||||
..Default::default()
|
||||
},
|
||||
TimeUnit::Millisecond,
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
/// Test scenario: Ensure single-sample accumulation works.
|
||||
#[test]
|
||||
fn raw_duration_works() {
|
||||
common::enable_test_logging();
|
||||
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let tmpname = dir.path().to_path_buf();
|
||||
|
||||
let cfg = ConfigurationBuilder::new(true, tmpname, "firefox-desktop")
|
||||
.with_server_endpoint("invalid-test-host")
|
||||
.build();
|
||||
common::initialize(cfg);
|
||||
|
||||
metrics::boo.accumulate_raw_duration(Duration::from_secs(1));
|
||||
|
||||
assert_eq!(
|
||||
1,
|
||||
metrics::boo.test_get_value(None).unwrap().count,
|
||||
"Single sample: single count"
|
||||
);
|
||||
|
||||
// Let's check overflow.
|
||||
metrics::boo.accumulate_raw_duration(Duration::from_nanos(u64::MAX));
|
||||
|
||||
assert_eq!(2, metrics::boo.test_get_value(None).unwrap().count);
|
||||
assert_eq!(
|
||||
1,
|
||||
metrics::boo.test_get_num_recorded_errors(ErrorType::InvalidOverflow)
|
||||
);
|
||||
|
||||
glean::shutdown(); // Cleanly shut down at the end of the test.
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ edition = "2018"
|
|||
license = "MPL-2.0"
|
||||
|
||||
[dependencies]
|
||||
glean = "60.0.0"
|
||||
glean = "60.1.0"
|
||||
log = "0.4"
|
||||
nserror = { path = "../../../xpcom/rust/nserror" }
|
||||
nsstring = { path = "../../../xpcom/rust/nsstring" }
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ license = "MPL-2.0"
|
|||
[dependencies]
|
||||
bincode = "1.0"
|
||||
chrono = "0.4.10"
|
||||
glean = "60.0.0"
|
||||
glean = "60.1.0"
|
||||
inherent = "1.0.0"
|
||||
log = "0.4"
|
||||
nsstring = { path = "../../../../xpcom/rust/nsstring", optional = true }
|
||||
|
|
|
|||
|
|
@ -67,74 +67,6 @@ impl TimingDistributionMetric {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Accumulates a time duration sample for the provided metric.
|
||||
///
|
||||
/// Adds a count to the corresponding bucket in the timing distribution.
|
||||
/// Saturates at u64::MAX nanoseconds.
|
||||
///
|
||||
/// Prefer start() and stop_and_accumulate() where possible.
|
||||
///
|
||||
/// Users of this API are responsible for ensuring the timing source used
|
||||
/// to calculate the duration is monotonic and consistent across platforms.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `duration` - The [`Duration`] of the accumulated sample.
|
||||
pub fn accumulate_raw_duration(&self, duration: Duration) {
|
||||
let sample = duration.as_nanos().try_into().unwrap_or_else(|_| {
|
||||
// TODO: Instrument this error
|
||||
log::warn!(
|
||||
"Elapsed nanoseconds larger than fits into 64-bytes. Saturating at u64::MAX."
|
||||
);
|
||||
u64::MAX
|
||||
});
|
||||
// May be unused in builds without gecko.
|
||||
let _sample_ms = duration.as_millis().try_into().unwrap_or_else(|_| {
|
||||
// TODO: Instrument this error
|
||||
log::warn!(
|
||||
"Elapsed milliseconds larger than fits into 32-bytes. Saturating at u32::MAX."
|
||||
);
|
||||
u32::MAX
|
||||
});
|
||||
match self {
|
||||
TimingDistributionMetric::Parent {
|
||||
id: _metric_id,
|
||||
inner,
|
||||
} => {
|
||||
#[cfg(feature = "with_gecko")]
|
||||
{
|
||||
extern "C" {
|
||||
fn GIFFT_TimingDistributionAccumulateRawMillis(metric_id: u32, sample: u32);
|
||||
}
|
||||
// SAFETY: using only primitives, no return value.
|
||||
unsafe {
|
||||
GIFFT_TimingDistributionAccumulateRawMillis(_metric_id.0, _sample_ms);
|
||||
}
|
||||
}
|
||||
inner.accumulate_raw_samples_nanos(vec![sample]);
|
||||
}
|
||||
TimingDistributionMetric::Child(c) => {
|
||||
#[cfg(feature = "with_gecko")]
|
||||
{
|
||||
extern "C" {
|
||||
fn GIFFT_TimingDistributionAccumulateRawMillis(metric_id: u32, sample: u32);
|
||||
}
|
||||
// SAFETY: using only primitives, no return value.
|
||||
unsafe {
|
||||
GIFFT_TimingDistributionAccumulateRawMillis(c.metric_id.0, _sample_ms);
|
||||
}
|
||||
}
|
||||
with_ipc_payload(move |payload| {
|
||||
if let Some(v) = payload.timing_samples.get_mut(&c.metric_id) {
|
||||
v.push(sample);
|
||||
} else {
|
||||
payload.timing_samples.insert(c.metric_id, vec![sample]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inherent]
|
||||
|
|
@ -386,6 +318,74 @@ impl TimingDistribution for TimingDistributionMetric {
|
|||
}
|
||||
}
|
||||
|
||||
/// Accumulates a time duration sample for the provided metric.
|
||||
///
|
||||
/// Adds a count to the corresponding bucket in the timing distribution.
|
||||
/// Saturates at u64::MAX nanoseconds.
|
||||
///
|
||||
/// Prefer start() and stop_and_accumulate() where possible.
|
||||
///
|
||||
/// Users of this API are responsible for ensuring the timing source used
|
||||
/// to calculate the duration is monotonic and consistent across platforms.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `duration` - The [`Duration`] of the accumulated sample.
|
||||
pub fn accumulate_raw_duration(&self, duration: Duration) {
|
||||
let sample = duration.as_nanos().try_into().unwrap_or_else(|_| {
|
||||
// TODO: Instrument this error
|
||||
log::warn!(
|
||||
"Elapsed nanoseconds larger than fits into 64-bytes. Saturating at u64::MAX."
|
||||
);
|
||||
u64::MAX
|
||||
});
|
||||
// May be unused in builds without gecko.
|
||||
let _sample_ms = duration.as_millis().try_into().unwrap_or_else(|_| {
|
||||
// TODO: Instrument this error
|
||||
log::warn!(
|
||||
"Elapsed milliseconds larger than fits into 32-bytes. Saturating at u32::MAX."
|
||||
);
|
||||
u32::MAX
|
||||
});
|
||||
match self {
|
||||
TimingDistributionMetric::Parent {
|
||||
id: _metric_id,
|
||||
inner,
|
||||
} => {
|
||||
#[cfg(feature = "with_gecko")]
|
||||
{
|
||||
extern "C" {
|
||||
fn GIFFT_TimingDistributionAccumulateRawMillis(metric_id: u32, sample: u32);
|
||||
}
|
||||
// SAFETY: using only primitives, no return value.
|
||||
unsafe {
|
||||
GIFFT_TimingDistributionAccumulateRawMillis(_metric_id.0, _sample_ms);
|
||||
}
|
||||
}
|
||||
inner.accumulate_raw_duration(duration);
|
||||
}
|
||||
TimingDistributionMetric::Child(c) => {
|
||||
#[cfg(feature = "with_gecko")]
|
||||
{
|
||||
extern "C" {
|
||||
fn GIFFT_TimingDistributionAccumulateRawMillis(metric_id: u32, sample: u32);
|
||||
}
|
||||
// SAFETY: using only primitives, no return value.
|
||||
unsafe {
|
||||
GIFFT_TimingDistributionAccumulateRawMillis(c.metric_id.0, _sample_ms);
|
||||
}
|
||||
}
|
||||
with_ipc_payload(move |payload| {
|
||||
if let Some(v) = payload.timing_samples.get_mut(&c.metric_id) {
|
||||
v.push(sample);
|
||||
} else {
|
||||
payload.timing_samples.insert(c.metric_id, vec![sample]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// **Exported for test purposes.**
|
||||
///
|
||||
/// Gets the currently stored value of the metric.
|
||||
|
|
|
|||
Loading…
Reference in a new issue