Bug 1963027 - Update to Glean v64.2.0 r=chutten,supply-chain-reviewers,mach-reviewers,ahochheiden
Differential Revision: https://phabricator.services.mozilla.com/D246926
This commit is contained in:
committed by
jrediger@mozilla.com
parent
0dd34d4e02
commit
9888dfdbf9
12
Cargo.lock
generated
12
Cargo.lock
generated
@@ -2641,9 +2641,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "glean"
|
||||
version = "64.1.1"
|
||||
version = "64.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95024f4707705270208e36983976cbac235dd7fc33c9f1cb0dee396ec1ce295d"
|
||||
checksum = "3bbaa151992ac45799a3779a3ff9d9ce1412a91f982b54f95ac85124e96f870c"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"glean-core",
|
||||
@@ -2651,13 +2651,14 @@ dependencies = [
|
||||
"log",
|
||||
"once_cell",
|
||||
"whatsys",
|
||||
"wr_malloc_size_of",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glean-core"
|
||||
version = "64.1.1"
|
||||
version = "64.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ca0df94fb37669287b77e8aa300913ad1d14426d7f9e443b0ce1185349c817e"
|
||||
checksum = "ec64dd5ecb37f04def90b179759c8906c95c895c392b444b5b67f868ffa4bedc"
|
||||
dependencies = [
|
||||
"android_logger",
|
||||
"bincode",
|
||||
@@ -2665,6 +2666,7 @@ dependencies = [
|
||||
"crossbeam-channel",
|
||||
"flate2",
|
||||
"log",
|
||||
"malloc_size_of_derive",
|
||||
"once_cell",
|
||||
"oslog",
|
||||
"rkv",
|
||||
@@ -2674,6 +2676,7 @@ dependencies = [
|
||||
"time 0.1.45",
|
||||
"uniffi",
|
||||
"uuid",
|
||||
"wr_malloc_size_of",
|
||||
"zeitstempel",
|
||||
]
|
||||
|
||||
@@ -7847,6 +7850,7 @@ version = "0.2.0"
|
||||
dependencies = [
|
||||
"app_units",
|
||||
"euclid",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -68,7 +68,7 @@ uniffi_bindgen = "0.29.1"
|
||||
# Shared across multiple application-services consumers.
|
||||
rusqlite = "0.33.0"
|
||||
# Shared across multiple glean consumers.
|
||||
glean = "=64.1.1"
|
||||
glean = "=64.2.0"
|
||||
|
||||
# Explicitly specify what our profiles use. The opt-level setting here is
|
||||
# a total fiction; see the setup of MOZ_RUST_DEFAULT_FLAGS for what the
|
||||
@@ -255,6 +255,8 @@ midir = { git = "https://github.com/mozilla/midir.git", rev = "85156e360a37d8517
|
||||
# Allow webrender to have a versioned dependency on the older crate on crates.io
|
||||
# in order to build standalone.
|
||||
malloc_size_of_derive = { path = "xpcom/rust/malloc_size_of_derive" }
|
||||
# Use the in-tree code instead of pulling it in. It matches the crates.io version
|
||||
wr_malloc_size_of = { path = "gfx/wr/wr_malloc_size_of" }
|
||||
|
||||
# objc 0.2.7 + fa7ca43b862861dd1cd000d7ad01e6e0266cda13
|
||||
objc = { git = "https://github.com/glandium/rust-objc", rev = "4de89f5aa9851ceca4d40e7ac1e2759410c04324" }
|
||||
|
||||
33
gfx/wr/Cargo.lock
generated
33
gfx/wr/Cargo.lock
generated
@@ -982,9 +982,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "glean"
|
||||
version = "64.1.1"
|
||||
version = "64.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95024f4707705270208e36983976cbac235dd7fc33c9f1cb0dee396ec1ce295d"
|
||||
checksum = "3bbaa151992ac45799a3779a3ff9d9ce1412a91f982b54f95ac85124e96f870c"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"glean-core",
|
||||
@@ -992,13 +992,14 @@ dependencies = [
|
||||
"log",
|
||||
"once_cell",
|
||||
"whatsys",
|
||||
"wr_malloc_size_of",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glean-core"
|
||||
version = "64.1.1"
|
||||
version = "64.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ca0df94fb37669287b77e8aa300913ad1d14426d7f9e443b0ce1185349c817e"
|
||||
checksum = "ec64dd5ecb37f04def90b179759c8906c95c895c392b444b5b67f868ffa4bedc"
|
||||
dependencies = [
|
||||
"android_logger",
|
||||
"bincode",
|
||||
@@ -1006,6 +1007,7 @@ dependencies = [
|
||||
"crossbeam-channel",
|
||||
"flate2",
|
||||
"log",
|
||||
"malloc_size_of_derive",
|
||||
"once_cell",
|
||||
"oslog",
|
||||
"rkv",
|
||||
@@ -1015,6 +1017,7 @@ dependencies = [
|
||||
"time",
|
||||
"uniffi",
|
||||
"uuid",
|
||||
"wr_malloc_size_of",
|
||||
"zeitstempel",
|
||||
]
|
||||
|
||||
@@ -1571,13 +1574,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "malloc_size_of_derive"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "632647502a8bfa82458c07134791fffa7a719f00427d1afd79c3cb6d4960a982"
|
||||
checksum = "f44db74bde26fdf427af23f1d146c211aed857c59e3be750cf2617f6b0b05c94"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"syn 1.0.91",
|
||||
"synstructure 0.12.6",
|
||||
"syn 2.0.32",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1989,7 +1992,7 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.32",
|
||||
"synstructure 0.13.1",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2643,18 +2646,6 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "synstructure"
|
||||
version = "0.12.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.91",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "synstructure"
|
||||
version = "0.13.1"
|
||||
|
||||
@@ -9,7 +9,7 @@ members = [
|
||||
resolver = "2"
|
||||
|
||||
[workspace.dependencies]
|
||||
glean = "=64.1.1"
|
||||
glean = "=64.2.0"
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
@@ -29,3 +29,4 @@ opt-level = 2
|
||||
firefox-on-glean = { path = "fog" }
|
||||
# use a patched version of glutin that works on android
|
||||
glutin = { version = "0.28", git = "https://github.com/jamienicol/glutin", branch="wr" }
|
||||
wr_malloc_size_of = { path = "wr_malloc_size_of" }
|
||||
|
||||
@@ -32,7 +32,6 @@ packages = [
|
||||
"rustc-hash",
|
||||
# transition to syn 2 is underway.
|
||||
"syn",
|
||||
"synstructure",
|
||||
# Requires an update to clap v4
|
||||
"textwrap",
|
||||
# Can be fixed by removing time dependency - see bug 1765324
|
||||
|
||||
@@ -80,7 +80,7 @@ serialization = "1.8.1"
|
||||
|
||||
# Mozilla versions
|
||||
apilint = "0.5.4"
|
||||
mozilla-glean = "64.1.1"
|
||||
mozilla-glean = "64.2.0"
|
||||
|
||||
# Testing versions
|
||||
androidx-test = "1.6.1"
|
||||
|
||||
@@ -104,7 +104,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==64.1.1:telemetry will not be collected
|
||||
pypi-optional:glean-sdk==64.2.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).
|
||||
|
||||
@@ -258,15 +258,15 @@ user-login = "jrmuizel"
|
||||
user-name = "Jeff Muizelaar"
|
||||
|
||||
[[publisher.glean]]
|
||||
version = "64.1.1"
|
||||
when = "2025-04-10"
|
||||
version = "64.2.0"
|
||||
when = "2025-04-28"
|
||||
user-id = 48
|
||||
user-login = "badboy"
|
||||
user-name = "Jan-Erik Rediger"
|
||||
|
||||
[[publisher.glean-core]]
|
||||
version = "64.1.1"
|
||||
when = "2025-04-10"
|
||||
version = "64.2.0"
|
||||
when = "2025-04-28"
|
||||
user-id = 48
|
||||
user-login = "badboy"
|
||||
user-name = "Jan-Erik Rediger"
|
||||
|
||||
File diff suppressed because one or more lines are too long
11
third_party/rust/glean-core/Cargo.toml
vendored
11
third_party/rust/glean-core/Cargo.toml
vendored
@@ -13,7 +13,7 @@
|
||||
edition = "2021"
|
||||
rust-version = "1.82"
|
||||
name = "glean-core"
|
||||
version = "64.1.1"
|
||||
version = "64.2.0"
|
||||
authors = [
|
||||
"Jan-Erik Rediger <jrediger@mozilla.com>",
|
||||
"The Glean Team <glean-team@mozilla.com>",
|
||||
@@ -147,6 +147,15 @@ version = "1.0.19"
|
||||
[dependencies.log]
|
||||
version = "0.4.8"
|
||||
|
||||
[dependencies.malloc_size_of]
|
||||
version = "0.2.0"
|
||||
features = ["once_cell"]
|
||||
default-features = false
|
||||
package = "wr_malloc_size_of"
|
||||
|
||||
[dependencies.malloc_size_of_derive]
|
||||
version = "0.1.3"
|
||||
|
||||
[dependencies.once_cell]
|
||||
version = "1.18.0"
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
use std::sync::atomic::{AtomicU8, Ordering};
|
||||
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
|
||||
use crate::error::{Error, ErrorKind};
|
||||
use crate::metrics::labeled::validate_dynamic_label;
|
||||
use crate::Glean;
|
||||
@@ -12,7 +14,7 @@ use serde::{Deserialize, Serialize};
|
||||
/// The supported metrics' lifetimes.
|
||||
///
|
||||
/// A metric's lifetime determines when its stored data gets reset.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default, MallocSizeOf)]
|
||||
#[repr(i32)] // Use i32 to be compatible with our JNA definition
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum Lifetime {
|
||||
@@ -50,7 +52,7 @@ impl TryFrom<i32> for Lifetime {
|
||||
}
|
||||
|
||||
/// The common set of data shared across all different metric types.
|
||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||
#[derive(Default, Debug, Clone, Deserialize, Serialize, MallocSizeOf)]
|
||||
pub struct CommonMetricData {
|
||||
/// The metric's name.
|
||||
pub name: String,
|
||||
@@ -73,9 +75,10 @@ pub struct CommonMetricData {
|
||||
pub dynamic_label: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
#[derive(Default, Debug, MallocSizeOf)]
|
||||
pub struct CommonMetricDataInternal {
|
||||
pub inner: CommonMetricData,
|
||||
#[ignore_malloc_size_of = "atomic integers never allocate (bug 1960589)"]
|
||||
pub disabled: AtomicU8,
|
||||
}
|
||||
|
||||
|
||||
6
third_party/rust/glean-core/src/core/mod.rs
vendored
6
third_party/rust/glean-core/src/core/mod.rs
vendored
@@ -9,6 +9,7 @@ use std::sync::{Arc, Mutex};
|
||||
use std::time::Duration;
|
||||
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use once_cell::sync::OnceCell;
|
||||
|
||||
use crate::database::Database;
|
||||
@@ -147,7 +148,7 @@ where
|
||||
///
|
||||
/// In specific language bindings, this is usually wrapped in a singleton and all metric recording goes to a single instance of this object.
|
||||
/// In the Rust core, it is possible to create multiple instances, which is used in testing.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, MallocSizeOf)]
|
||||
pub struct Glean {
|
||||
upload_enabled: bool,
|
||||
pub(crate) data_store: Option<Database>,
|
||||
@@ -159,6 +160,7 @@ pub struct Glean {
|
||||
data_path: PathBuf,
|
||||
application_id: String,
|
||||
ping_registry: HashMap<String, PingType>,
|
||||
#[ignore_malloc_size_of = "external non-allocating type"]
|
||||
start_time: DateTime<FixedOffset>,
|
||||
max_events: u32,
|
||||
is_first_run: bool,
|
||||
@@ -166,7 +168,9 @@ pub struct Glean {
|
||||
debug: DebugOptions,
|
||||
pub(crate) app_build: String,
|
||||
pub(crate) schedule_metrics_pings: bool,
|
||||
#[ignore_malloc_size_of = "atomic integers never allocate (bug 1960589)"]
|
||||
pub(crate) remote_settings_epoch: AtomicU8,
|
||||
#[ignore_malloc_size_of = "TODO: Expose Glean's inner memory allocations (bug 1960592)"]
|
||||
pub(crate) remote_settings_config: Arc<Mutex<RemoteSettingsConfig>>,
|
||||
pub(crate) with_timestamps: bool,
|
||||
pub(crate) ping_schedule: HashMap<String, Vec<String>>,
|
||||
|
||||
@@ -7,10 +7,11 @@ use crate::metrics::{
|
||||
};
|
||||
use crate::{CommonMetricData, Lifetime};
|
||||
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
/// Metrics included in every ping as `client_info`.
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug, Default, MallocSizeOf)]
|
||||
pub struct ClientInfoMetrics {
|
||||
/// The build identifier generated by the CI system (e.g. "1234/A").
|
||||
pub app_build: String,
|
||||
|
||||
29
third_party/rust/glean-core/src/database/mod.rs
vendored
29
third_party/rust/glean-core/src/database/mod.rs
vendored
@@ -16,6 +16,7 @@ use std::time::{Duration, Instant};
|
||||
|
||||
use crate::ErrorKind;
|
||||
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
use rkv::{StoreError, StoreOptions};
|
||||
|
||||
/// Unwrap a `Result`s `Ok` value or do the specified action.
|
||||
@@ -143,6 +144,34 @@ pub struct Database {
|
||||
pub(crate) write_timings: RefCell<Vec<i64>>,
|
||||
}
|
||||
|
||||
impl MallocSizeOf for Database {
|
||||
fn size_of(&self, _ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
|
||||
// TODO(bug 1960592): Fill in gaps.
|
||||
|
||||
/*
|
||||
let mut n = 0;
|
||||
|
||||
n += 0; // self.rkv.size_of(ops) -- not implemented.
|
||||
n += 0; // self.user_store.size_of(ops) -- not implemented.
|
||||
|
||||
n += self
|
||||
.ping_lifetime_data
|
||||
.as_ref()
|
||||
.map(|_data| {
|
||||
// TODO(bug 1960592): servo's malloc_size_of implements it for BTreeMap.
|
||||
//let lock = data.read().unwrap();
|
||||
//(*lock).size_of(ops)
|
||||
0
|
||||
})
|
||||
.unwrap_or(0);
|
||||
|
||||
n
|
||||
*/
|
||||
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for Database {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
fmt.debug_struct("Database")
|
||||
|
||||
13
third_party/rust/glean-core/src/debug.rs
vendored
13
third_party/rust/glean-core/src/debug.rs
vendored
@@ -27,12 +27,16 @@
|
||||
|
||||
use std::env;
|
||||
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
|
||||
const GLEAN_LOG_PINGS: &str = "GLEAN_LOG_PINGS";
|
||||
const GLEAN_DEBUG_VIEW_TAG: &str = "GLEAN_DEBUG_VIEW_TAG";
|
||||
const GLEAN_SOURCE_TAGS: &str = "GLEAN_SOURCE_TAGS";
|
||||
const GLEAN_MAX_SOURCE_TAGS: usize = 5;
|
||||
|
||||
/// A representation of all of Glean's debug options.
|
||||
#[derive(MallocSizeOf)]
|
||||
pub struct DebugOptions {
|
||||
/// Option to log the payload of pings that are successfully assembled into a ping request.
|
||||
pub log_pings: DebugOption<bool>,
|
||||
@@ -83,6 +87,15 @@ pub struct DebugOption<T, E = fn(String) -> Option<T>, V = fn(&T) -> bool> {
|
||||
validation: Option<V>,
|
||||
}
|
||||
|
||||
impl<T, E, V> MallocSizeOf for DebugOption<T, E, V>
|
||||
where
|
||||
T: MallocSizeOf,
|
||||
{
|
||||
fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
|
||||
self.env.size_of(ops) + self.value.size_of(ops)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E, V> DebugOption<T, E, V>
|
||||
where
|
||||
T: Clone,
|
||||
|
||||
@@ -14,6 +14,8 @@ use std::sync::{Mutex, RwLock};
|
||||
|
||||
use chrono::{DateTime, FixedOffset, Utc};
|
||||
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value as JsonValue};
|
||||
|
||||
@@ -28,7 +30,7 @@ use crate::Result;
|
||||
use crate::{CommonMetricData, CounterMetric, Lifetime};
|
||||
|
||||
/// Represents the recorded data for a single event.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, MallocSizeOf)]
|
||||
#[cfg_attr(test, derive(Default))]
|
||||
pub struct RecordedEvent {
|
||||
/// The timestamp of when the event was recorded.
|
||||
@@ -54,7 +56,9 @@ pub struct RecordedEvent {
|
||||
}
|
||||
|
||||
/// Represents the stored data for a single event.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[derive(
|
||||
Debug, Clone, Deserialize, Serialize, PartialEq, Eq, malloc_size_of_derive::MallocSizeOf,
|
||||
)]
|
||||
struct StoredEvent {
|
||||
#[serde(flatten)]
|
||||
event: RecordedEvent,
|
||||
@@ -99,6 +103,12 @@ pub struct EventDatabase {
|
||||
file_lock: Mutex<()>,
|
||||
}
|
||||
|
||||
impl MallocSizeOf for EventDatabase {
|
||||
fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
|
||||
self.event_stores.read().unwrap().size_of(ops)
|
||||
}
|
||||
}
|
||||
|
||||
impl EventDatabase {
|
||||
/// Creates a new event database.
|
||||
///
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use once_cell::sync::OnceCell;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -56,7 +57,7 @@ fn exponential_range(min: u64, max: u64, bucket_count: usize) -> Vec<u64> {
|
||||
///
|
||||
/// Buckets are pre-computed at instantiation with an exponential distribution from `min` to `max`
|
||||
/// and `bucket_count` buckets.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, MallocSizeOf)]
|
||||
pub struct PrecomputedExponential {
|
||||
// Don't serialize the (potentially large) array of ranges, instead compute them on first
|
||||
// access.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{Bucketing, Histogram};
|
||||
@@ -18,7 +19,7 @@ use crate::util::floating_point_context::FloatingPointContext;
|
||||
/// i = ⌊n log<sub>base</sub>(𝑥)⌋
|
||||
///
|
||||
/// In other words, there are n buckets for each power of `base` magnitude.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, MallocSizeOf)]
|
||||
pub struct Functional {
|
||||
exponent: f64,
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use std::cmp;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use once_cell::sync::OnceCell;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -36,7 +37,7 @@ fn linear_range(min: u64, max: u64, count: usize) -> Vec<u64> {
|
||||
///
|
||||
/// Buckets are pre-computed at instantiation with a linear distribution from `min` to `max`
|
||||
/// and `bucket_count` buckets.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, MallocSizeOf)]
|
||||
pub struct PrecomputedLinear {
|
||||
// Don't serialize the (potentially large) array of ranges, instead compute them on first
|
||||
// access.
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
use std::any::TypeId;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use once_cell::sync::OnceCell;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -21,7 +22,7 @@ mod functional;
|
||||
mod linear;
|
||||
|
||||
/// Different kinds of histograms.
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, MallocSizeOf)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum HistogramType {
|
||||
/// A histogram with linear distributed buckets.
|
||||
@@ -59,7 +60,7 @@ impl TryFrom<i32> for HistogramType {
|
||||
/// assert_eq!(10, hist.count());
|
||||
/// assert_eq!(55, hist.sum());
|
||||
/// ```
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, MallocSizeOf)]
|
||||
pub struct Histogram<B> {
|
||||
/// Mapping bucket's minimum to sample count.
|
||||
values: HashMap<u64, u64>,
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
|
||||
use super::{metrics::*, CommonMetricData, LabeledMetricData, Lifetime};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, MallocSizeOf)]
|
||||
pub struct CoreMetrics {
|
||||
pub client_id: UuidMetric,
|
||||
pub first_run_date: DatetimeMetric,
|
||||
@@ -19,7 +21,7 @@ pub struct CoreMetrics {
|
||||
pub distribution_name: StringMetric,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, MallocSizeOf)]
|
||||
pub struct AdditionalMetrics {
|
||||
/// The number of times we encountered an IO error
|
||||
/// when writing a pending ping to disk.
|
||||
@@ -199,7 +201,7 @@ impl AdditionalMetrics {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, MallocSizeOf)]
|
||||
pub struct UploadMetrics {
|
||||
pub ping_upload_failure: LabeledMetric<CounterMetric>,
|
||||
pub discarded_exceeding_pings_size: MemoryDistributionMetric,
|
||||
@@ -323,7 +325,7 @@ impl UploadMetrics {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, MallocSizeOf)]
|
||||
pub struct DatabaseMetrics {
|
||||
pub size: MemoryDistributionMetric,
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// 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/.
|
||||
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
|
||||
use crate::metrics::PingType;
|
||||
|
||||
/// Glean-provided pings, all enabled by default.
|
||||
@@ -10,7 +12,7 @@ use crate::metrics::PingType;
|
||||
/// This might get auto-generated when the Rust API lands ([Bug 1579146](https://bugzilla.mozilla.org/show_bug.cgi?id=1579146)).
|
||||
///
|
||||
/// They are parsed and registered by the platform-specific wrappers, but might be used Glean-internal directly.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, MallocSizeOf)]
|
||||
pub struct InternalPings {
|
||||
pub baseline: PingType,
|
||||
pub metrics: PingType,
|
||||
|
||||
7
third_party/rust/glean-core/src/lib.rs
vendored
7
third_party/rust/glean-core/src/lib.rs
vendored
@@ -26,6 +26,7 @@ use std::time::Duration;
|
||||
|
||||
use crossbeam_channel::unbounded;
|
||||
use log::LevelFilter;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use once_cell::sync::{Lazy, OnceCell};
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -113,7 +114,7 @@ static INIT_HANDLES: Lazy<Arc<Mutex<Vec<std::thread::JoinHandle<()>>>>> =
|
||||
Lazy::new(|| Arc::new(Mutex::new(Vec::new())));
|
||||
|
||||
/// Configuration for Glean
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, MallocSizeOf)]
|
||||
pub struct InternalConfiguration {
|
||||
/// Whether upload should be enabled.
|
||||
pub upload_enabled: bool,
|
||||
@@ -135,6 +136,8 @@ pub struct InternalConfiguration {
|
||||
/// Whether Glean should, on init, trim its event storage to only the registered pings.
|
||||
pub trim_data_to_registered_pings: bool,
|
||||
/// The internal logging level.
|
||||
/// ignore
|
||||
#[ignore_malloc_size_of = "external non-allocating type"]
|
||||
pub log_level: Option<LevelFilter>,
|
||||
/// The rate at which pings may be uploaded before they are throttled.
|
||||
pub rate_limit: Option<PingRateLimit>,
|
||||
@@ -158,7 +161,7 @@ pub struct InternalConfiguration {
|
||||
}
|
||||
|
||||
/// How to specify the rate at which pings may be uploaded before they are throttled.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, MallocSizeOf)]
|
||||
pub struct PingRateLimit {
|
||||
/// Length of time in seconds of a ping uploading interval.
|
||||
pub seconds_per_interval: u64,
|
||||
|
||||
@@ -16,6 +16,7 @@ use crate::CommonMetricData;
|
||||
use crate::Glean;
|
||||
|
||||
use chrono::{DateTime, Datelike, FixedOffset, TimeZone, Timelike};
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
|
||||
/// A datetime type.
|
||||
///
|
||||
@@ -23,7 +24,7 @@ use chrono::{DateTime, Datelike, FixedOffset, TimeZone, Timelike};
|
||||
pub type ChronoDatetime = DateTime<FixedOffset>;
|
||||
|
||||
/// Representation of a date, time and timezone.
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
#[derive(Clone, PartialEq, Eq, MallocSizeOf)]
|
||||
pub struct Datetime {
|
||||
/// The year, e.g. 2021.
|
||||
pub year: i32,
|
||||
|
||||
@@ -4,8 +4,11 @@
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::collections::{hash_map::Entry, HashMap};
|
||||
use std::mem;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
|
||||
use crate::common_metric_data::{CommonMetricData, CommonMetricDataInternal};
|
||||
use crate::error_recording::{record_error, test_get_num_recorded_errors, ErrorType};
|
||||
use crate::histogram::HistogramType;
|
||||
@@ -86,6 +89,32 @@ pub struct LabeledMetric<T> {
|
||||
label_map: Mutex<HashMap<String, Arc<T>>>,
|
||||
}
|
||||
|
||||
impl<T: MallocSizeOf> ::malloc_size_of::MallocSizeOf for LabeledMetric<T> {
|
||||
fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
|
||||
let map = self.label_map.lock().unwrap();
|
||||
|
||||
// Copy of `MallocShallowSizeOf` implementation for `HashMap<K, V>` in `wr_malloc_size_of`.
|
||||
// Note: An instantiated submetric is behind an `Arc`.
|
||||
// `size_of` should only be called from a single thread to avoid double-counting.
|
||||
let shallow_size = if ops.has_malloc_enclosing_size_of() {
|
||||
map.values()
|
||||
.next()
|
||||
.map_or(0, |v| unsafe { ops.malloc_enclosing_size_of(v) })
|
||||
} else {
|
||||
map.capacity()
|
||||
* (mem::size_of::<String>() + mem::size_of::<T>() + mem::size_of::<usize>())
|
||||
};
|
||||
|
||||
let mut map_size = shallow_size;
|
||||
for (k, v) in map.iter() {
|
||||
map_size += k.size_of(ops);
|
||||
map_size += v.size_of(ops);
|
||||
}
|
||||
|
||||
self.labels.size_of(ops) + self.submetric.size_of(ops) + map_size
|
||||
}
|
||||
}
|
||||
|
||||
/// Sealed traits protect against downstream implementations.
|
||||
///
|
||||
/// We wrap it in a private module that is inaccessible outside of this module.
|
||||
|
||||
58
third_party/rust/glean-core/src/metrics/mod.rs
vendored
58
third_party/rust/glean-core/src/metrics/mod.rs
vendored
@@ -8,6 +8,7 @@ use std::collections::HashMap;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
pub use serde_json::Value as JsonValue;
|
||||
@@ -152,6 +153,32 @@ pub enum Metric {
|
||||
Object(String),
|
||||
}
|
||||
|
||||
impl MallocSizeOf for Metric {
|
||||
fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
|
||||
match self {
|
||||
Metric::Boolean(m) => m.size_of(ops),
|
||||
Metric::Counter(m) => m.size_of(ops),
|
||||
// Custom distributions are in the same section, no matter what bucketing.
|
||||
Metric::CustomDistributionExponential(m) => m.size_of(ops),
|
||||
Metric::CustomDistributionLinear(m) => m.size_of(ops),
|
||||
Metric::Datetime(_a, b) => b.size_of(ops),
|
||||
Metric::Experiment(m) => m.size_of(ops),
|
||||
Metric::Quantity(m) => m.size_of(ops),
|
||||
Metric::Rate(a, b) => a.size_of(ops) + b.size_of(ops),
|
||||
Metric::String(m) => m.size_of(ops),
|
||||
Metric::StringList(m) => m.size_of(ops),
|
||||
Metric::Timespan(a, b) => a.size_of(ops) + b.size_of(ops),
|
||||
Metric::TimingDistribution(m) => m.size_of(ops),
|
||||
Metric::Url(m) => m.size_of(ops),
|
||||
Metric::Uuid(m) => m.size_of(ops),
|
||||
Metric::MemoryDistribution(m) => m.size_of(ops),
|
||||
Metric::Jwe(m) => m.size_of(ops),
|
||||
Metric::Text(m) => m.size_of(ops),
|
||||
Metric::Object(m) => m.size_of(ops),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A [`MetricType`] describes common behavior across all metrics.
|
||||
pub trait MetricType {
|
||||
/// Access the stored metadata
|
||||
@@ -312,3 +339,34 @@ impl Metric {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! impl_malloc_size_of_for_metric {
|
||||
($ty:ident) => {
|
||||
impl ::malloc_size_of::MallocSizeOf for $ty {
|
||||
fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
|
||||
// Note: `meta` is likely s behind an `Arc`.
|
||||
// `size_of` should only be called from a single thread to avoid double-counting.
|
||||
self.meta().size_of(ops)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl_malloc_size_of_for_metric!(BooleanMetric);
|
||||
impl_malloc_size_of_for_metric!(CounterMetric);
|
||||
impl_malloc_size_of_for_metric!(CustomDistributionMetric);
|
||||
impl_malloc_size_of_for_metric!(DatetimeMetric);
|
||||
impl_malloc_size_of_for_metric!(DenominatorMetric);
|
||||
impl_malloc_size_of_for_metric!(EventMetric);
|
||||
impl_malloc_size_of_for_metric!(ExperimentMetric);
|
||||
impl_malloc_size_of_for_metric!(MemoryDistributionMetric);
|
||||
impl_malloc_size_of_for_metric!(NumeratorMetric);
|
||||
impl_malloc_size_of_for_metric!(ObjectMetric);
|
||||
impl_malloc_size_of_for_metric!(QuantityMetric);
|
||||
impl_malloc_size_of_for_metric!(RateMetric);
|
||||
impl_malloc_size_of_for_metric!(StringMetric);
|
||||
impl_malloc_size_of_for_metric!(StringListMetric);
|
||||
impl_malloc_size_of_for_metric!(TextMetric);
|
||||
impl_malloc_size_of_for_metric!(TimespanMetric);
|
||||
impl_malloc_size_of_for_metric!(UrlMetric);
|
||||
impl_malloc_size_of_for_metric!(UuidMetric);
|
||||
|
||||
10
third_party/rust/glean-core/src/metrics/ping.rs
vendored
10
third_party/rust/glean-core/src/metrics/ping.rs
vendored
@@ -10,6 +10,7 @@ use crate::ping::PingMaker;
|
||||
use crate::upload::PingPayload;
|
||||
use crate::Glean;
|
||||
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use uuid::Uuid;
|
||||
|
||||
/// Stores information about a ping.
|
||||
@@ -19,6 +20,7 @@ use uuid::Uuid;
|
||||
#[derive(Clone)]
|
||||
pub struct PingType(Arc<InnerPing>);
|
||||
|
||||
#[derive(MallocSizeOf)]
|
||||
struct InnerPing {
|
||||
/// The name of the ping.
|
||||
pub name: String,
|
||||
@@ -65,6 +67,14 @@ impl fmt::Debug for PingType {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::malloc_size_of::MallocSizeOf for PingType {
|
||||
fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
|
||||
// Note: This is behind an `Arc`.
|
||||
// `size_of` should only be called from a single thread to avoid double-counting.
|
||||
self.0.size_of(ops)
|
||||
}
|
||||
}
|
||||
|
||||
// IMPORTANT:
|
||||
//
|
||||
// When changing this implementation, make sure all the operations are
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Map as JsonMap, Value as JsonValue};
|
||||
|
||||
/// Deserialized experiment data.
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, MallocSizeOf)]
|
||||
pub struct RecordedExperiment {
|
||||
/// The experiment's branch as set through [`set_experiment_active`](crate::glean_set_experiment_active).
|
||||
pub branch: String,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Represents a list of metrics and an associated boolean property
|
||||
@@ -17,7 +18,7 @@ use serde::{Deserialize, Serialize};
|
||||
/// "category.metric_name": true
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, MallocSizeOf)]
|
||||
pub struct RemoteSettingsConfig {
|
||||
/// This is a `HashMap` consisting of base_identifiers as keys
|
||||
/// and bool values representing an override for the `disabled`
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::error::{Error, ErrorKind};
|
||||
|
||||
/// Different resolutions supported by the time related
|
||||
/// metric types (e.g. DatetimeMetric).
|
||||
#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq, MallocSizeOf)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[repr(i32)] // use i32 to be compatible with our JNA definition
|
||||
pub enum TimeUnit {
|
||||
|
||||
@@ -8,6 +8,8 @@ use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Duration;
|
||||
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
|
||||
use crate::common_metric_data::CommonMetricDataInternal;
|
||||
use crate::error_recording::{record_error, test_get_num_recorded_errors, ErrorType};
|
||||
use crate::histogram::{Functional, Histogram};
|
||||
@@ -36,7 +38,7 @@ const MAX_SAMPLE_TIME: u64 = 1000 * 1000 * 1000 * 60 * 10;
|
||||
///
|
||||
/// Its internals are considered private,
|
||||
/// but due to UniFFI's behavior we expose its field for now.
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, MallocSizeOf)]
|
||||
pub struct TimerId {
|
||||
/// This timer's id.
|
||||
pub id: u64,
|
||||
@@ -65,6 +67,17 @@ pub struct TimingDistributionMetric {
|
||||
start_times: Arc<Mutex<HashMap<TimerId, u64>>>,
|
||||
}
|
||||
|
||||
impl ::malloc_size_of::MallocSizeOf for TimingDistributionMetric {
|
||||
fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
|
||||
// Note: This is behind an `Arc`.
|
||||
// `size_of` should only be called on the main thread to avoid double-counting.
|
||||
self.meta.size_of(ops)
|
||||
+ self.time_unit.size_of(ops)
|
||||
+ self.next_id.size_of(ops)
|
||||
+ self.start_times.lock().unwrap().size_of(ops)
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a snapshot of the histogram with a time unit.
|
||||
///
|
||||
/// The snapshot can be serialized into the payload format.
|
||||
|
||||
@@ -9,6 +9,8 @@ use std::fs::{self, File};
|
||||
use std::io::{BufRead, BufReader};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -16,7 +18,7 @@ use super::request::HeaderMap;
|
||||
use crate::{DELETION_REQUEST_PINGS_DIRECTORY, PENDING_PINGS_DIRECTORY};
|
||||
|
||||
/// A representation of the data extracted from a ping file,
|
||||
#[derive(Clone, Debug, Default)]
|
||||
#[derive(Clone, Debug, Default, MallocSizeOf)]
|
||||
pub struct PingPayload {
|
||||
/// The ping's doc_id.
|
||||
pub document_id: String,
|
||||
@@ -41,6 +43,28 @@ pub struct PingPayloadsByDirectory {
|
||||
pub deletion_request_pings: Vec<(u64, PingPayload)>,
|
||||
}
|
||||
|
||||
impl MallocSizeOf for PingPayloadsByDirectory {
|
||||
fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
|
||||
// SAFETY: We own the referenced `Vec`s and can hand out pointers to them
|
||||
// to an external function.
|
||||
let shallow_size = unsafe {
|
||||
ops.malloc_size_of(self.pending_pings.as_ptr())
|
||||
+ ops.malloc_size_of(self.deletion_request_pings.as_ptr())
|
||||
};
|
||||
|
||||
let mut n = shallow_size;
|
||||
for elem in self.pending_pings.iter() {
|
||||
n += elem.0.size_of(ops);
|
||||
n += elem.1.size_of(ops);
|
||||
}
|
||||
for elem in self.deletion_request_pings.iter() {
|
||||
n += elem.0.size_of(ops);
|
||||
n += elem.1.size_of(ops);
|
||||
}
|
||||
n
|
||||
}
|
||||
}
|
||||
|
||||
impl PingPayloadsByDirectory {
|
||||
/// Extends the data of this instance of PingPayloadsByDirectory
|
||||
/// with the data from another instance of PingPayloadsByDirectory.
|
||||
@@ -108,7 +132,7 @@ pub fn process_metadata(path: &str, metadata: &str) -> Option<PingMetadata> {
|
||||
}
|
||||
|
||||
/// Manages the pings directories.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, MallocSizeOf)]
|
||||
pub struct PingDirectoryManager {
|
||||
/// Path to the pending pings directory.
|
||||
pending_pings_dir: PathBuf,
|
||||
|
||||
46
third_party/rust/glean-core/src/upload/mod.rs
vendored
46
third_party/rust/glean-core/src/upload/mod.rs
vendored
@@ -14,6 +14,7 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::collections::VecDeque;
|
||||
use std::mem;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
|
||||
use std::sync::{Arc, RwLock, RwLockWriteGuard};
|
||||
@@ -21,6 +22,8 @@ use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use chrono::Utc;
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
|
||||
use crate::error::ErrorKind;
|
||||
use crate::TimerId;
|
||||
@@ -41,7 +44,7 @@ mod result;
|
||||
|
||||
const WAIT_TIME_FOR_PING_PROCESSING: u64 = 1000; // in milliseconds
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, MallocSizeOf)]
|
||||
struct RateLimiter {
|
||||
/// The instant the current interval has started.
|
||||
started: Option<Instant>,
|
||||
@@ -216,6 +219,47 @@ pub struct PingUploadManager {
|
||||
in_flight: RwLock<HashMap<String, (TimerId, TimerId)>>,
|
||||
}
|
||||
|
||||
impl MallocSizeOf for PingUploadManager {
|
||||
fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
|
||||
let shallow_size = {
|
||||
let queue = self.queue.read().unwrap();
|
||||
if ops.has_malloc_enclosing_size_of() {
|
||||
if let Some(front) = queue.front() {
|
||||
// SAFETY: The front element is a valid interior pointer and thus valid to pass
|
||||
// to an external function.
|
||||
unsafe { ops.malloc_enclosing_size_of(front) }
|
||||
} else {
|
||||
// This assumes that no memory is allocated when the VecDeque is empty.
|
||||
0
|
||||
}
|
||||
} else {
|
||||
// If `ops` can't estimate the size of a pointer,
|
||||
// we can estimate the allocation size by the size of each element and the
|
||||
// allocated capacity.
|
||||
queue.capacity() * mem::size_of::<PingRequest>()
|
||||
}
|
||||
};
|
||||
|
||||
let mut n = shallow_size
|
||||
+ self.directory_manager.size_of(ops)
|
||||
// SAFETY: We own this arc and can pass a pointer to it to an external function.
|
||||
+ unsafe { ops.malloc_size_of(self.processed_pending_pings.as_ptr()) }
|
||||
+ self.cached_pings.read().unwrap().size_of(ops)
|
||||
+ self.rate_limiter.as_ref().map(|rl| {
|
||||
let lock = rl.read().unwrap();
|
||||
(*lock).size_of(ops)
|
||||
}).unwrap_or(0)
|
||||
+ self.language_binding_name.size_of(ops)
|
||||
+ self.upload_metrics.size_of(ops)
|
||||
+ self.policy.size_of(ops);
|
||||
|
||||
let in_flight = self.in_flight.read().unwrap();
|
||||
n += in_flight.size_of(ops);
|
||||
|
||||
n
|
||||
}
|
||||
}
|
||||
|
||||
impl PingUploadManager {
|
||||
/// Creates a new PingUploadManager.
|
||||
///
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
//! Policies for ping storage, uploading and requests.
|
||||
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
|
||||
const MAX_RECOVERABLE_FAILURES: u32 = 3;
|
||||
const MAX_WAIT_ATTEMPTS: u32 = 3;
|
||||
const MAX_PING_BODY_SIZE: usize = 1024 * 1024; // 1 MB
|
||||
@@ -18,7 +20,7 @@ const MAX_PENDING_PINGS_DIRECTORY_SIZE: u64 = 10 * 1024 * 1024; // 10MB
|
||||
const MAX_PENDING_PINGS_COUNT: u64 = 250;
|
||||
|
||||
/// A struct holding the values for all the policies related to ping storage, uploading and requests.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, MallocSizeOf)]
|
||||
pub struct Policy {
|
||||
/// The maximum recoverable failures allowed per uploading window.
|
||||
///
|
||||
|
||||
2
third_party/rust/glean/.cargo-checksum.json
vendored
2
third_party/rust/glean/.cargo-checksum.json
vendored
@@ -1 +1 @@
|
||||
{"files":{"Cargo.lock":"add20d32d164cac0a56ddac41468eaf0b23b9616f32e94a8434f5841d14b3a97","Cargo.toml":"99107d6ac4ef4ff33e2d206e8498875df879001e4621ba94e9d4ccf14267f39c","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5627cc81e6187ab6c2b4dff061af16d559edcab64ba786bac39daa69c703c595","src/common_test.rs":"c86cccfb7da1506cfed29cb2ee13d839b7ac7cffdfd70793c9665bb44e0b684f","src/configuration.rs":"de65ab99a26b4547be20803bc195cb50a6ab40b1a3f49a2e6230fed5a9d7a8d8","src/core_metrics.rs":"fef8fb4e5fa57c179836c6eb2cf59278fe3b8b036dbe57b0ff02971b4acd822f","src/lib.rs":"998359d04ba0f71aaa360b8999c716f22c9efaf1ff4e1fdce80f1d3af5e584b0","src/net/http_uploader.rs":"0a94ac3cd87cb021529dee46d537765ab8d923e0f4ac7615225e878d3739e6dc","src/net/mod.rs":"09ba010b03d045fd8a2ccbe4f205c5275bb622bceb34cb81a0aa8f7d33804e2e","src/private/event.rs":"f299c79e4e2acb657f06004f3038bd8909e287719458566bc7f96262d8665e62","src/private/mod.rs":"66e90c41de74d1e80c5d3f49b8f1a86b8396be0b8c4a80f1a28903fe6d105ecf","src/private/object.rs":"7f17a7a658e8f7aa19a6bedf70f60f3f42713316d5d60298d682bb045caaafb7","src/private/ping.rs":"d2fb45e9e178ff6b17aa9c1b5258dfcd2ed91a2b43b44dec826de256ef5e8520","src/system.rs":"d602804a72258bfd65e51c571946631732ee27d81342d8aa406e47fdd241bbfa","src/test.rs":"8ff4d5072d23d9fbf5444e474d21b41a31e86a37e2a25fc2f2a92976e7642cbb","tests/collection_enabled.rs":"3327a949dbdeec493d661261abda68ffa71acc50ab24cba4fde5302749e6f16b","tests/collection_enabled_bin.rs":"d3a6458b84012a447e5cb792f2292a06951ed252fad803b9166b437bacba542c","tests/common/mod.rs":"2fd391c5eb45f56fdfa3261dd631406c67ed36b10b0d5432febe2483da5c9d89","tests/custom_distribution_buffered.rs":"47c13d1f39adf3881e10caa19e0c08235f08958809e234bf37a79d37d7322cd5","tests/init_fails.rs":"ca7fa1b3dd6a21a9e005b7a4f0a18664c4bceb952dd463db8316500f72280d5b","tests/interruptible_shutdown.rs":"3d954bbe47d4f5fd103c51a4ff99f151662143c25c826da9734a00cd215909b9","tests/memory_distribution_buffered.rs":"db487475a5cf17a0864ccf150984ebdd28bf616573772cf678246cc1bdbcbc0f","tests/metric_metadata.rs":"05c947d3decf0a3281378dbb108080a05319ad8f130af5b07f9b049b80e5f04f","tests/near-empty-c0ffee-db.safe.bin":"89afb3bb8fc94430fb0ed0fe55f85f3f8bcc8fd0fed69a9df13cc560294ec9f5","tests/never_init.rs":"51fff5618f6603bc0945d70131698d10a1c6275f43bbc22a2de5807f8a79229f","tests/no_time_to_init.rs":"2ede23df6618ff1cb5ae3b7bbf95900ad0fd92072afa2e0319bf147b4f75cefc","tests/overflowing_preinit.rs":"985e140460a100986fd051ce901b787a3a7a9747a856cd06066b740ac7d2381c","tests/persist_ping_lifetime_nopanic.rs":"18379d3ffbf4a2c8c684c04ff7a0660b86dfbbb447db2d24dfed6073cb7ddf8f","tests/schema.rs":"23b49005402b914e55a0c5c155f30c2662c609f79be78d1385ec25b3600b3547","tests/simple.rs":"15c76a1b5a336fd6abfbdebafc971f5c6a9b75107ddbca65f0031cde3e2886da","tests/test-delayed-ping-data.sh":"4a6db98b4df6b77898ace6a8b4e8b4c60d3e5c44873bbf38c62e83583e27a3ff","tests/test-enabled-pings.sh":"06656e38f63e65475006b107dd6bd179b0cbaa1fad1470de38e679e91a9315a3","tests/test-pending-gets-removed.sh":"e335f2f00fa97a61b6d94e0005fb3b9de8c8db8076111a67ca47d85392039ea9","tests/test-ping-lifetime-flush.sh":"e8f118ea2f6fd973809e38d5e828a03cfccfe0b0f497ccde5ec92d6d1380c071","tests/test-shutdown-blocking.sh":"a44d8d4bbe2ee3ede9e48121150ae7a5386025160c5cef2181ca142232c5fb27","tests/test-thread-crashing.sh":"f3cd0cc8a7b4fe82bef0fe6fbfbbe45fbad6da3afe0f82578bc5cfb2d6527ac6","tests/timing_distribution_buffered.rs":"501f7289c0c28f0ab83838c88b058999b19436d0f2b693be0787513d7b67e06d","tests/timing_distribution_single_sample.rs":"4f9498b6ef29913da0356027efe5f572c81d2f426e8538c068b54a1cfa33c1b8","tests/upload_timing.rs":"b3b9db197bc2ec41556388969a6bf289e7ef19e05b9019bc2bd98c823fcf6ea3","tests/uploader_capabilities.rs":"347f19e534a50a211ea179d6818631270d1b4ec468098e6b6abcde1e4a6a9bca"},"package":"95024f4707705270208e36983976cbac235dd7fc33c9f1cb0dee396ec1ce295d"}
|
||||
{"files":{"Cargo.lock":"49b2fdc584b3bfa871d157e015ff8b476e39b470a6963e72e6a3528885e7214f","Cargo.toml":"c04f3098d1fafab6dd25d1556d68467e968c7eb4228d28922807e67f3d720076","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5627cc81e6187ab6c2b4dff061af16d559edcab64ba786bac39daa69c703c595","src/common_test.rs":"c86cccfb7da1506cfed29cb2ee13d839b7ac7cffdfd70793c9665bb44e0b684f","src/configuration.rs":"de65ab99a26b4547be20803bc195cb50a6ab40b1a3f49a2e6230fed5a9d7a8d8","src/core_metrics.rs":"fef8fb4e5fa57c179836c6eb2cf59278fe3b8b036dbe57b0ff02971b4acd822f","src/lib.rs":"998359d04ba0f71aaa360b8999c716f22c9efaf1ff4e1fdce80f1d3af5e584b0","src/net/http_uploader.rs":"0a94ac3cd87cb021529dee46d537765ab8d923e0f4ac7615225e878d3739e6dc","src/net/mod.rs":"09ba010b03d045fd8a2ccbe4f205c5275bb622bceb34cb81a0aa8f7d33804e2e","src/private/event.rs":"9986dd55abc668533fe3a5c510155fde66446bf8829b323043e5b2b9c8864495","src/private/mod.rs":"66e90c41de74d1e80c5d3f49b8f1a86b8396be0b8c4a80f1a28903fe6d105ecf","src/private/object.rs":"5f3e5d065824ea82aa70156e875a82a079656e07753685d732f4d2aa1be1aedb","src/private/ping.rs":"8ec514e88c1fcba13560522c83e39643edf7d74a3dc733e273984c46c781b2d2","src/system.rs":"d602804a72258bfd65e51c571946631732ee27d81342d8aa406e47fdd241bbfa","src/test.rs":"8ff4d5072d23d9fbf5444e474d21b41a31e86a37e2a25fc2f2a92976e7642cbb","tests/collection_enabled.rs":"3327a949dbdeec493d661261abda68ffa71acc50ab24cba4fde5302749e6f16b","tests/collection_enabled_bin.rs":"d3a6458b84012a447e5cb792f2292a06951ed252fad803b9166b437bacba542c","tests/common/mod.rs":"2fd391c5eb45f56fdfa3261dd631406c67ed36b10b0d5432febe2483da5c9d89","tests/custom_distribution_buffered.rs":"47c13d1f39adf3881e10caa19e0c08235f08958809e234bf37a79d37d7322cd5","tests/init_fails.rs":"ca7fa1b3dd6a21a9e005b7a4f0a18664c4bceb952dd463db8316500f72280d5b","tests/interruptible_shutdown.rs":"3d954bbe47d4f5fd103c51a4ff99f151662143c25c826da9734a00cd215909b9","tests/memory_distribution_buffered.rs":"db487475a5cf17a0864ccf150984ebdd28bf616573772cf678246cc1bdbcbc0f","tests/metric_metadata.rs":"05c947d3decf0a3281378dbb108080a05319ad8f130af5b07f9b049b80e5f04f","tests/near-empty-c0ffee-db.safe.bin":"89afb3bb8fc94430fb0ed0fe55f85f3f8bcc8fd0fed69a9df13cc560294ec9f5","tests/never_init.rs":"51fff5618f6603bc0945d70131698d10a1c6275f43bbc22a2de5807f8a79229f","tests/no_time_to_init.rs":"2ede23df6618ff1cb5ae3b7bbf95900ad0fd92072afa2e0319bf147b4f75cefc","tests/overflowing_preinit.rs":"985e140460a100986fd051ce901b787a3a7a9747a856cd06066b740ac7d2381c","tests/persist_ping_lifetime_nopanic.rs":"18379d3ffbf4a2c8c684c04ff7a0660b86dfbbb447db2d24dfed6073cb7ddf8f","tests/schema.rs":"23b49005402b914e55a0c5c155f30c2662c609f79be78d1385ec25b3600b3547","tests/simple.rs":"15c76a1b5a336fd6abfbdebafc971f5c6a9b75107ddbca65f0031cde3e2886da","tests/test-delayed-ping-data.sh":"4a6db98b4df6b77898ace6a8b4e8b4c60d3e5c44873bbf38c62e83583e27a3ff","tests/test-enabled-pings.sh":"06656e38f63e65475006b107dd6bd179b0cbaa1fad1470de38e679e91a9315a3","tests/test-pending-gets-removed.sh":"e335f2f00fa97a61b6d94e0005fb3b9de8c8db8076111a67ca47d85392039ea9","tests/test-ping-lifetime-flush.sh":"e8f118ea2f6fd973809e38d5e828a03cfccfe0b0f497ccde5ec92d6d1380c071","tests/test-shutdown-blocking.sh":"a44d8d4bbe2ee3ede9e48121150ae7a5386025160c5cef2181ca142232c5fb27","tests/test-thread-crashing.sh":"f3cd0cc8a7b4fe82bef0fe6fbfbbe45fbad6da3afe0f82578bc5cfb2d6527ac6","tests/timing_distribution_buffered.rs":"501f7289c0c28f0ab83838c88b058999b19436d0f2b693be0787513d7b67e06d","tests/timing_distribution_single_sample.rs":"4f9498b6ef29913da0356027efe5f572c81d2f426e8538c068b54a1cfa33c1b8","tests/upload_timing.rs":"b3b9db197bc2ec41556388969a6bf289e7ef19e05b9019bc2bd98c823fcf6ea3","tests/uploader_capabilities.rs":"347f19e534a50a211ea179d6818631270d1b4ec468098e6b6abcde1e4a6a9bca"},"package":"3bbaa151992ac45799a3779a3ff9d9ce1412a91f982b54f95ac85124e96f870c"}
|
||||
40
third_party/rust/glean/Cargo.lock
generated
vendored
40
third_party/rust/glean/Cargo.lock
generated
vendored
@@ -242,7 +242,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "glean"
|
||||
version = "64.1.1"
|
||||
version = "64.2.0"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"env_logger",
|
||||
@@ -256,13 +256,14 @@ dependencies = [
|
||||
"serde_json",
|
||||
"tempfile",
|
||||
"whatsys",
|
||||
"wr_malloc_size_of",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glean-core"
|
||||
version = "64.1.1"
|
||||
version = "64.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ca0df94fb37669287b77e8aa300913ad1d14426d7f9e443b0ce1185349c817e"
|
||||
checksum = "ec64dd5ecb37f04def90b179759c8906c95c895c392b444b5b67f868ffa4bedc"
|
||||
dependencies = [
|
||||
"android_logger",
|
||||
"bincode",
|
||||
@@ -270,6 +271,7 @@ dependencies = [
|
||||
"crossbeam-channel",
|
||||
"flate2",
|
||||
"log",
|
||||
"malloc_size_of_derive",
|
||||
"once_cell",
|
||||
"oslog",
|
||||
"rkv",
|
||||
@@ -279,6 +281,7 @@ dependencies = [
|
||||
"time",
|
||||
"uniffi",
|
||||
"uuid",
|
||||
"wr_malloc_size_of",
|
||||
"zeitstempel",
|
||||
]
|
||||
|
||||
@@ -419,6 +422,17 @@ version = "0.4.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
|
||||
|
||||
[[package]]
|
||||
name = "malloc_size_of_derive"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f44db74bde26fdf427af23f1d146c211aed857c59e3be750cf2617f6b0b05c94"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"syn",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
@@ -748,6 +762,17 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "synstructure"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.8.0"
|
||||
@@ -1100,6 +1125,15 @@ version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||
|
||||
[[package]]
|
||||
name = "wr_malloc_size_of"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c7c9a8bd19d73e907d610b14b3545475c98ad9581e36f1b67044fd209b66c69"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zeitstempel"
|
||||
version = "0.1.1"
|
||||
|
||||
10
third_party/rust/glean/Cargo.toml
vendored
10
third_party/rust/glean/Cargo.toml
vendored
@@ -13,7 +13,7 @@
|
||||
edition = "2021"
|
||||
rust-version = "1.82"
|
||||
name = "glean"
|
||||
version = "64.1.1"
|
||||
version = "64.2.0"
|
||||
authors = [
|
||||
"Jan-Erik Rediger <jrediger@mozilla.com>",
|
||||
"The Glean Team <glean-team@mozilla.com>",
|
||||
@@ -115,7 +115,7 @@ path = "tests/uploader_capabilities.rs"
|
||||
version = "0.5"
|
||||
|
||||
[dependencies.glean-core]
|
||||
version = "64.1.1"
|
||||
version = "64.2.0"
|
||||
|
||||
[dependencies.inherent]
|
||||
version = "1"
|
||||
@@ -123,6 +123,12 @@ version = "1"
|
||||
[dependencies.log]
|
||||
version = "0.4.8"
|
||||
|
||||
[dependencies.malloc_size_of]
|
||||
version = "0.2.0"
|
||||
features = ["once_cell"]
|
||||
default-features = false
|
||||
package = "wr_malloc_size_of"
|
||||
|
||||
[dependencies.once_cell]
|
||||
version = "1.18.0"
|
||||
|
||||
|
||||
8
third_party/rust/glean/src/private/event.rs
vendored
8
third_party/rust/glean/src/private/event.rs
vendored
@@ -5,6 +5,8 @@
|
||||
use inherent::inherent;
|
||||
use std::{collections::HashMap, marker::PhantomData};
|
||||
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
|
||||
use glean_core::{metrics::MetricIdentifier, traits};
|
||||
|
||||
use crate::{ErrorType, RecordedEvent};
|
||||
@@ -25,6 +27,12 @@ pub struct EventMetric<K> {
|
||||
extra_keys: PhantomData<K>,
|
||||
}
|
||||
|
||||
impl<K> MallocSizeOf for EventMetric<K> {
|
||||
fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
|
||||
self.inner.size_of(ops)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K> MetricIdentifier<'a> for EventMetric<K> {
|
||||
fn get_identifiers(&'a self) -> (&'a str, &'a str, Option<&'a str>) {
|
||||
self.inner.get_identifiers()
|
||||
|
||||
8
third_party/rust/glean/src/private/object.rs
vendored
8
third_party/rust/glean/src/private/object.rs
vendored
@@ -4,6 +4,8 @@
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
|
||||
use glean_core::metrics::{JsonValue, MetricIdentifier};
|
||||
use glean_core::traits;
|
||||
|
||||
@@ -25,6 +27,12 @@ pub struct ObjectMetric<K> {
|
||||
object_type: PhantomData<K>,
|
||||
}
|
||||
|
||||
impl<K> MallocSizeOf for ObjectMetric<K> {
|
||||
fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
|
||||
self.inner.size_of(ops)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K> MetricIdentifier<'a> for ObjectMetric<K> {
|
||||
fn get_identifiers(&'a self) -> (&'a str, &'a str, Option<&'a str>) {
|
||||
self.inner.get_identifiers()
|
||||
|
||||
20
third_party/rust/glean/src/private/ping.rs
vendored
20
third_party/rust/glean/src/private/ping.rs
vendored
@@ -2,7 +2,12 @@
|
||||
// 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/.
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::{
|
||||
mem,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
|
||||
type BoxedCallback = Box<dyn FnOnce(Option<&str>) + Send + 'static>;
|
||||
|
||||
@@ -19,6 +24,19 @@ pub struct PingType {
|
||||
test_callback: Arc<Mutex<Option<BoxedCallback>>>,
|
||||
}
|
||||
|
||||
impl MallocSizeOf for PingType {
|
||||
fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
|
||||
self.inner.size_of(ops)
|
||||
+ self
|
||||
.test_callback
|
||||
.lock()
|
||||
.unwrap()
|
||||
.as_ref()
|
||||
.map(|cb| mem::size_of_val(cb))
|
||||
.unwrap_or(0)
|
||||
}
|
||||
}
|
||||
|
||||
impl PingType {
|
||||
/// Creates a new ping type.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user