зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1852921 - Upgrade to Glean v54.0.0 r=chutten,supply-chain-reviewers,mach-reviewers,ahochheiden
Differential Revision: https://phabricator.services.mozilla.com/D188084
This commit is contained in:
Родитель
15a403f212
Коммит
8dd4f8a708
|
@ -2232,9 +2232,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "glean"
|
||||
version = "53.2.0"
|
||||
version = "54.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df470f5f41c8fc6113bd48fa18e0f1a8193e1e2b1f3942f8255b064e60db42ff"
|
||||
checksum = "5ca520309b2eb189c3834b4d9752286615a1cc04798715805a6da8f0d7f16941"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"crossbeam-channel",
|
||||
|
@ -2252,9 +2252,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "glean-core"
|
||||
version = "53.2.0"
|
||||
version = "54.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f72ce41516d772676db57c87fee1c99545bbda4b430793f24d0c81918cfbd8a"
|
||||
checksum = "d07e342f3f81264ddd21a0cdd37888052d501fa76cdff73948e972731009708e"
|
||||
dependencies = [
|
||||
"android_logger",
|
||||
"bincode",
|
||||
|
|
|
@ -36,7 +36,7 @@ allprojects {
|
|||
topsrcdir = gradle.mozconfig.topsrcdir
|
||||
topobjdir = gradle.mozconfig.topobjdir
|
||||
|
||||
gleanVersion = "53.2.0"
|
||||
gleanVersion = "54.0.0"
|
||||
if (gleanVersion != getRustVersionFor("glean")) {
|
||||
throw new StopExecutionException("Mismatched Glean version, expected: ${gleanVersion}," +
|
||||
" found ${getRustVersionFor("glean")}")
|
||||
|
|
|
@ -987,9 +987,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "glean"
|
||||
version = "53.2.0"
|
||||
version = "54.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df470f5f41c8fc6113bd48fa18e0f1a8193e1e2b1f3942f8255b064e60db42ff"
|
||||
checksum = "5ca520309b2eb189c3834b4d9752286615a1cc04798715805a6da8f0d7f16941"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"crossbeam-channel",
|
||||
|
@ -1007,9 +1007,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "glean-core"
|
||||
version = "53.2.0"
|
||||
version = "54.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f72ce41516d772676db57c87fee1c99545bbda4b430793f24d0c81918cfbd8a"
|
||||
checksum = "d07e342f3f81264ddd21a0cdd37888052d501fa76cdff73948e972731009708e"
|
||||
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 = "53.2.0"
|
||||
glean = "54.0.0"
|
||||
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 = "53.2.0", optional = true }
|
||||
glean = { version = "54.0.0", optional = true }
|
||||
firefox-on-glean = { version = "0.1.0", optional = true }
|
||||
serde = { optional = true, version = "1.0", features = ["serde_derive"] }
|
||||
|
||||
|
|
|
@ -88,7 +88,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==53.2.0:telemetry will not be collected
|
||||
pypi-optional:glean-sdk==54.0.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).
|
||||
|
|
|
@ -711,10 +711,6 @@ criteria = "safe-to-deploy"
|
|||
version = "0.8.5"
|
||||
criteria = "safe-to-deploy"
|
||||
|
||||
[[exemptions.rand_chacha]]
|
||||
version = "0.3.1"
|
||||
criteria = "safe-to-deploy"
|
||||
|
||||
[[exemptions.remove_dir_all]]
|
||||
version = "0.5.3"
|
||||
criteria = "safe-to-deploy"
|
||||
|
|
|
@ -36,27 +36,6 @@ user-id = 1258
|
|||
user-login = "padenot"
|
||||
user-name = "Paul Adenot"
|
||||
|
||||
[[publisher.authenticator]]
|
||||
version = "0.4.0-alpha.15"
|
||||
when = "2023-05-15"
|
||||
user-id = 175410
|
||||
user-login = "jschanck"
|
||||
user-name = "John Schanck"
|
||||
|
||||
[[publisher.authenticator]]
|
||||
version = "0.4.0-alpha.18"
|
||||
when = "2023-06-20"
|
||||
user-id = 175410
|
||||
user-login = "jschanck"
|
||||
user-name = "John Schanck"
|
||||
|
||||
[[publisher.authenticator]]
|
||||
version = "0.4.0-alpha.19"
|
||||
when = "2023-08-15"
|
||||
user-id = 175410
|
||||
user-login = "jschanck"
|
||||
user-name = "John Schanck"
|
||||
|
||||
[[publisher.authenticator]]
|
||||
version = "0.4.0-alpha.20"
|
||||
when = "2023-08-24"
|
||||
|
@ -226,15 +205,15 @@ user-login = "jrmuizel"
|
|||
user-name = "Jeff Muizelaar"
|
||||
|
||||
[[publisher.glean]]
|
||||
version = "53.2.0"
|
||||
when = "2023-08-02"
|
||||
version = "54.0.0"
|
||||
when = "2023-09-13"
|
||||
user-id = 48
|
||||
user-login = "badboy"
|
||||
user-name = "Jan-Erik Rediger"
|
||||
|
||||
[[publisher.glean-core]]
|
||||
version = "53.2.0"
|
||||
when = "2023-08-02"
|
||||
version = "54.0.0"
|
||||
when = "2023-09-13"
|
||||
user-id = 48
|
||||
user-login = "badboy"
|
||||
user-name = "Jan-Erik Rediger"
|
||||
|
@ -246,13 +225,6 @@ user-id = 84794
|
|||
user-login = "jamienicol"
|
||||
user-name = "Jamie Nicol"
|
||||
|
||||
[[publisher.headers]]
|
||||
version = "0.3.8"
|
||||
when = "2022-09-02"
|
||||
user-id = 359
|
||||
user-login = "seanmonstar"
|
||||
user-name = "Sean McArthur"
|
||||
|
||||
[[publisher.headers]]
|
||||
version = "0.3.9"
|
||||
when = "2023-08-31"
|
||||
|
@ -392,13 +364,6 @@ when = "2023-04-13"
|
|||
user-id = 101233
|
||||
user-login = "le-automaton"
|
||||
|
||||
[[publisher.proc-macro2]]
|
||||
version = "1.0.59"
|
||||
when = "2023-05-25"
|
||||
user-id = 3618
|
||||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.proc-macro2]]
|
||||
version = "1.0.66"
|
||||
when = "2023-07-16"
|
||||
|
@ -504,13 +469,6 @@ user-id = 2017
|
|||
user-login = "mbrubeck"
|
||||
user-name = "Matt Brubeck"
|
||||
|
||||
[[publisher.syn]]
|
||||
version = "1.0.107"
|
||||
when = "2022-12-18"
|
||||
user-id = 3618
|
||||
user-login = "dtolnay"
|
||||
user-name = "David Tolnay"
|
||||
|
||||
[[publisher.syn]]
|
||||
version = "2.0.18"
|
||||
when = "2023-05-26"
|
||||
|
@ -1024,12 +982,6 @@ who = "Johan Andersson <opensource@embark-studios.com>"
|
|||
criteria = "safe-to-deploy"
|
||||
version = "1.0.58"
|
||||
|
||||
[[audits.embark-studios.audits.cty]]
|
||||
who = "Johan Andersson <opensource@embark-studios.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
version = "0.2.2"
|
||||
notes = "Inspected it and is a tiny crate with just type definitions"
|
||||
|
||||
[[audits.embark-studios.audits.derive_more]]
|
||||
who = "Johan Andersson <opensource@embark-studios.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -1251,6 +1203,11 @@ who = "David Cook <dcook@divviup.org>"
|
|||
criteria = "safe-to-deploy"
|
||||
delta = "1.17.2 -> 1.18.0"
|
||||
|
||||
[[audits.isrg.audits.rand_chacha]]
|
||||
who = "David Cook <dcook@divviup.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
version = "0.3.1"
|
||||
|
||||
[[audits.isrg.audits.rand_core]]
|
||||
who = "David Cook <dcook@divviup.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -1317,15 +1274,3 @@ criteria = "safe-to-deploy"
|
|||
version = "1.4.0"
|
||||
notes = "I have read over the macros, and audited the unsafe code."
|
||||
aggregated-from = "https://raw.githubusercontent.com/mozilla/cargo-vet/main/supply-chain/audits.toml"
|
||||
|
||||
[[audits.mozilla.audits.time]]
|
||||
who = "Kershaw Chang <kershaw@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.1.45 -> 0.3.17"
|
||||
aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml"
|
||||
|
||||
[[audits.mozilla.audits.time-macros]]
|
||||
who = "Kershaw Chang <kershaw@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
version = "0.2.6"
|
||||
aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml"
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -13,7 +13,7 @@
|
|||
edition = "2021"
|
||||
rust-version = "1.62"
|
||||
name = "glean-core"
|
||||
version = "53.2.0"
|
||||
version = "54.0.0"
|
||||
authors = [
|
||||
"Jan-Erik Rediger <jrediger@mozilla.com>",
|
||||
"The Glean Team <glean-team@mozilla.com>",
|
||||
|
|
|
@ -114,6 +114,7 @@ where
|
|||
/// trim_data_to_registered_pings: false,
|
||||
/// log_level: None,
|
||||
/// rate_limit: None,
|
||||
/// enable_event_timestamps: false,
|
||||
/// };
|
||||
/// let mut glean = Glean::new(cfg).unwrap();
|
||||
/// let ping = PingType::new("sample", true, false, vec![]);
|
||||
|
@ -156,6 +157,7 @@ pub struct Glean {
|
|||
pub(crate) schedule_metrics_pings: bool,
|
||||
pub(crate) remote_settings_epoch: AtomicU8,
|
||||
pub(crate) remote_settings_metrics_config: Arc<Mutex<MetricsEnabledConfig>>,
|
||||
pub(crate) with_timestamps: bool,
|
||||
}
|
||||
|
||||
impl Glean {
|
||||
|
@ -215,6 +217,7 @@ impl Glean {
|
|||
schedule_metrics_pings: false,
|
||||
remote_settings_epoch: AtomicU8::new(0),
|
||||
remote_settings_metrics_config: Arc::new(Mutex::new(MetricsEnabledConfig::new())),
|
||||
with_timestamps: cfg.enable_event_timestamps,
|
||||
};
|
||||
|
||||
// Ensuring these pings are registered.
|
||||
|
@ -302,6 +305,7 @@ impl Glean {
|
|||
trim_data_to_registered_pings: false,
|
||||
log_level: None,
|
||||
rate_limit: None,
|
||||
enable_event_timestamps: false,
|
||||
};
|
||||
|
||||
let mut glean = Self::new(cfg).unwrap();
|
||||
|
@ -551,6 +555,10 @@ impl Glean {
|
|||
&self.event_data_store
|
||||
}
|
||||
|
||||
pub(crate) fn with_timestamps(&self) -> bool {
|
||||
self.with_timestamps
|
||||
}
|
||||
|
||||
/// Gets the maximum number of events to store before sending a ping.
|
||||
pub fn get_max_events(&self) -> usize {
|
||||
self.max_events as usize
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::io::Write;
|
|||
use std::path::{Path, PathBuf};
|
||||
use std::sync::RwLock;
|
||||
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use chrono::{DateTime, FixedOffset, Utc};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value as JsonValue};
|
||||
|
@ -188,7 +188,13 @@ impl EventDatabase {
|
|||
..Default::default()
|
||||
};
|
||||
let startup = get_iso_time_string(glean.start_time(), TimeUnit::Minute);
|
||||
let extra = [("glean.startup.date".into(), startup)].into();
|
||||
let mut extra: HashMap<String, String> =
|
||||
[("glean.startup.date".into(), startup)].into();
|
||||
if glean.with_timestamps() {
|
||||
let now = Utc::now();
|
||||
let precise_timestamp = now.timestamp_millis() as u64;
|
||||
extra.insert("glean_timestamp".to_string(), precise_timestamp.to_string());
|
||||
}
|
||||
self.record(
|
||||
glean,
|
||||
&glean_restarted.into(),
|
||||
|
@ -279,7 +285,7 @@ impl EventDatabase {
|
|||
{
|
||||
let mut db = self.event_stores.write().unwrap(); // safe unwrap, only error case is poisoning
|
||||
for store_name in meta.inner.send_in_pings.iter() {
|
||||
let store = db.entry(store_name.to_string()).or_insert_with(Vec::new);
|
||||
let store = db.entry(store_name.to_string()).or_default();
|
||||
let execution_counter = CounterMetric::new(CommonMetricData {
|
||||
name: "execution_counter".into(),
|
||||
category: store_name.into(),
|
||||
|
|
|
@ -74,6 +74,7 @@ dictionary InternalConfiguration {
|
|||
boolean trim_data_to_registered_pings;
|
||||
LevelFilter? log_level;
|
||||
PingRateLimit? rate_limit;
|
||||
boolean enable_event_timestamps;
|
||||
};
|
||||
|
||||
// How to specify the rate pings may be uploaded before they are throttled.
|
||||
|
|
|
@ -130,6 +130,8 @@ pub struct InternalConfiguration {
|
|||
pub log_level: Option<LevelFilter>,
|
||||
/// The rate at which pings may be uploaded before they are throttled.
|
||||
pub rate_limit: Option<PingRateLimit>,
|
||||
/// (Experimental) Whether to add a wallclock timestamp to all events.
|
||||
pub enable_event_timestamps: bool,
|
||||
}
|
||||
|
||||
/// How to specify the rate at which pings may be uploaded before they are throttled.
|
||||
|
|
|
@ -12,6 +12,8 @@ use crate::util::truncate_string_at_boundary_with_error;
|
|||
use crate::CommonMetricData;
|
||||
use crate::Glean;
|
||||
|
||||
use chrono::Utc;
|
||||
|
||||
const MAX_LENGTH_EXTRA_KEY_VALUE: usize = 500;
|
||||
|
||||
/// An event metric.
|
||||
|
@ -68,8 +70,13 @@ impl EventMetric {
|
|||
/// If any key is not allowed, an error is reported and no event is recorded.
|
||||
pub fn record_with_time(&self, timestamp: u64, extra: HashMap<String, String>) {
|
||||
let metric = self.clone();
|
||||
|
||||
// Precise timestamp based on wallclock. Will be used if `enable_event_timestamps` is true.
|
||||
let now = Utc::now();
|
||||
let precise_timestamp = now.timestamp_millis() as u64;
|
||||
|
||||
crate::launch_with_glean(move |glean| {
|
||||
let sent = metric.record_sync(glean, timestamp, extra);
|
||||
let sent = metric.record_sync(glean, timestamp, extra, precise_timestamp);
|
||||
if sent {
|
||||
let state = crate::global_state().lock().unwrap();
|
||||
if let Err(e) = state.callbacks.trigger_upload() {
|
||||
|
@ -123,16 +130,25 @@ impl EventMetric {
|
|||
glean: &Glean,
|
||||
timestamp: u64,
|
||||
extra: HashMap<String, String>,
|
||||
precise_timestamp: u64,
|
||||
) -> bool {
|
||||
if !self.should_record(glean) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let extra_strings = match self.validate_extra(glean, extra) {
|
||||
let mut extra_strings = match self.validate_extra(glean, extra) {
|
||||
Ok(extra) => extra,
|
||||
Err(()) => return false,
|
||||
};
|
||||
|
||||
if glean.with_timestamps() {
|
||||
if extra_strings.is_none() {
|
||||
extra_strings.replace(Default::default());
|
||||
}
|
||||
let map = extra_strings.get_or_insert(Default::default());
|
||||
map.insert("glean_timestamp".to_string(), precise_timestamp.to_string());
|
||||
}
|
||||
|
||||
glean
|
||||
.event_storage()
|
||||
.record(glean, &self.meta, timestamp, extra_strings)
|
||||
|
|
|
@ -294,9 +294,7 @@ impl PingMaker {
|
|||
fn get_pings_dir(&self, data_path: &Path, ping_type: Option<&str>) -> std::io::Result<PathBuf> {
|
||||
// Use a special directory for deletion-request pings
|
||||
let pings_dir = match ping_type {
|
||||
Some(ping_type) if ping_type == "deletion-request" => {
|
||||
data_path.join(DELETION_REQUEST_PINGS_DIRECTORY)
|
||||
}
|
||||
Some("deletion-request") => data_path.join(DELETION_REQUEST_PINGS_DIRECTORY),
|
||||
_ => data_path.join(PENDING_PINGS_DIRECTORY),
|
||||
};
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ fn snapshot_labeled_metrics(
|
|||
metric: &Metric,
|
||||
) {
|
||||
let ping_section = format!("labeled_{}", metric.ping_section());
|
||||
let map = snapshot.entry(ping_section).or_insert_with(HashMap::new);
|
||||
let map = snapshot.entry(ping_section).or_default();
|
||||
|
||||
// Safe unwrap, the function is only called when the id does contain a '/'
|
||||
let (metric_id, label) = metric_id.split_once('/').unwrap();
|
||||
|
@ -90,9 +90,7 @@ impl StorageManager {
|
|||
if metric_id.contains('/') {
|
||||
snapshot_labeled_metrics(&mut snapshot, &metric_id, metric);
|
||||
} else {
|
||||
let map = snapshot
|
||||
.entry(metric.ping_section().into())
|
||||
.or_insert_with(HashMap::new);
|
||||
let map = snapshot.entry(metric.ping_section().into()).or_default();
|
||||
map.insert(metric_id, metric.as_json());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -61,6 +61,7 @@ pub fn new_glean(tempdir: Option<tempfile::TempDir>) -> (Glean, tempfile::TempDi
|
|||
trim_data_to_registered_pings: false,
|
||||
log_level: None,
|
||||
rate_limit: None,
|
||||
enable_event_timestamps: false,
|
||||
};
|
||||
let glean = Glean::new(cfg).unwrap();
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ fn record_properly_records_without_optional_arguments() {
|
|||
vec![],
|
||||
);
|
||||
|
||||
metric.record_sync(&glean, 1000, HashMap::new());
|
||||
metric.record_sync(&glean, 1000, HashMap::new(), 0);
|
||||
|
||||
for store_name in store_names {
|
||||
let events = metric.get_value(&glean, &*store_name).unwrap();
|
||||
|
@ -68,7 +68,7 @@ fn record_properly_records_with_optional_arguments() {
|
|||
.cloned()
|
||||
.collect();
|
||||
|
||||
metric.record_sync(&glean, 1000, extra);
|
||||
metric.record_sync(&glean, 1000, extra, 0);
|
||||
|
||||
for store_name in store_names {
|
||||
let events = metric.get_value(&glean, &*store_name).unwrap();
|
||||
|
@ -114,7 +114,7 @@ fn snapshot_correctly_clears_the_stores() {
|
|||
vec![],
|
||||
);
|
||||
|
||||
metric.record_sync(&glean, 1000, HashMap::new());
|
||||
metric.record_sync(&glean, 1000, HashMap::new(), 0);
|
||||
|
||||
let snapshot = glean
|
||||
.event_storage()
|
||||
|
@ -186,7 +186,7 @@ fn test_sending_of_event_ping_when_it_fills_up() {
|
|||
for i in 0..510 {
|
||||
let mut extra = HashMap::new();
|
||||
extra.insert("test_event_number".to_string(), i.to_string());
|
||||
click.record_sync(&glean, i, extra);
|
||||
click.record_sync(&glean, i, extra, 0);
|
||||
}
|
||||
|
||||
assert_eq!(10, click.get_value(&glean, "events").unwrap().len());
|
||||
|
@ -247,7 +247,7 @@ fn extra_keys_must_be_recorded_and_truncated_if_needed() {
|
|||
extra.insert("extra1".into(), test_value.to_string());
|
||||
extra.insert("truncatedExtra".into(), test_value_long.clone());
|
||||
|
||||
test_event.record_sync(&glean, 0, extra);
|
||||
test_event.record_sync(&glean, 0, extra, 0);
|
||||
|
||||
let snapshot = glean
|
||||
.event_storage()
|
||||
|
@ -281,9 +281,9 @@ fn snapshot_sorts_the_timestamps() {
|
|||
vec![],
|
||||
);
|
||||
|
||||
metric.record_sync(&glean, 1000, HashMap::new());
|
||||
metric.record_sync(&glean, 100, HashMap::new());
|
||||
metric.record_sync(&glean, 10000, HashMap::new());
|
||||
metric.record_sync(&glean, 1000, HashMap::new(), 0);
|
||||
metric.record_sync(&glean, 100, HashMap::new(), 0);
|
||||
metric.record_sync(&glean, 10000, HashMap::new(), 0);
|
||||
|
||||
let snapshot = glean
|
||||
.event_storage()
|
||||
|
@ -332,7 +332,7 @@ fn ensure_custom_ping_events_dont_overflow() {
|
|||
.is_err());
|
||||
|
||||
for _ in 0..500 {
|
||||
event.record_sync(&glean, 0, HashMap::new());
|
||||
event.record_sync(&glean, 0, HashMap::new(), 0);
|
||||
}
|
||||
assert!(test_get_num_recorded_errors(
|
||||
&glean,
|
||||
|
@ -342,7 +342,7 @@ fn ensure_custom_ping_events_dont_overflow() {
|
|||
.is_err());
|
||||
|
||||
// That should top us right up to the limit. Now for going over.
|
||||
event.record_sync(&glean, 0, HashMap::new());
|
||||
event.record_sync(&glean, 0, HashMap::new(), 0);
|
||||
assert!(
|
||||
test_get_num_recorded_errors(&glean, &event_meta.into(), ErrorType::InvalidOverflow)
|
||||
.is_err()
|
||||
|
@ -379,7 +379,7 @@ fn ensure_custom_ping_events_from_multiple_runs_work() {
|
|||
.flush_pending_events_on_startup(&glean, false));
|
||||
tempdir = dir;
|
||||
|
||||
event.record_sync(&glean, 10, HashMap::new());
|
||||
event.record_sync(&glean, 10, HashMap::new(), 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -391,7 +391,7 @@ fn ensure_custom_ping_events_from_multiple_runs_work() {
|
|||
|
||||
// Gotta use get_timestamp_ms or this event won't happen "after" the injected
|
||||
// glean.restarted event from `flush_pending_events_on_startup`.
|
||||
event.record_sync(&glean, get_timestamp_ms(), HashMap::new());
|
||||
event.record_sync(&glean, get_timestamp_ms(), HashMap::new(), 0);
|
||||
|
||||
let json = glean
|
||||
.event_storage()
|
||||
|
@ -431,7 +431,7 @@ fn event_storage_trimming() {
|
|||
{
|
||||
let (glean, dir) = new_glean(Some(tempdir));
|
||||
tempdir = dir;
|
||||
event.record_sync(&glean, 10, HashMap::new());
|
||||
event.record_sync(&glean, 10, HashMap::new(), 0);
|
||||
|
||||
assert_eq!(1, event.get_value(&glean, store_name).unwrap().len());
|
||||
assert_eq!(1, event.get_value(&glean, store_name_2).unwrap().len());
|
||||
|
@ -452,3 +452,55 @@ fn event_storage_trimming() {
|
|||
assert!(event.get_value(&glean, store_name_2).is_none());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_event_timestamps() {
|
||||
use glean_core::{Glean, InternalConfiguration};
|
||||
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let cfg = InternalConfiguration {
|
||||
data_path: dir.path().display().to_string(),
|
||||
application_id: GLOBAL_APPLICATION_ID.into(),
|
||||
language_binding_name: "Rust".into(),
|
||||
upload_enabled: true,
|
||||
max_events: None,
|
||||
delay_ping_lifetime_io: false,
|
||||
app_build: "Unknown".into(),
|
||||
use_core_mps: false,
|
||||
trim_data_to_registered_pings: false,
|
||||
log_level: None,
|
||||
rate_limit: None,
|
||||
enable_event_timestamps: true, // Enabling event timestamps
|
||||
};
|
||||
let glean = Glean::new(cfg).unwrap();
|
||||
|
||||
let store_name = "store-name";
|
||||
let event = EventMetric::new(
|
||||
CommonMetricData {
|
||||
name: "name".into(),
|
||||
category: "category".into(),
|
||||
send_in_pings: vec![store_name.into()],
|
||||
lifetime: Lifetime::Ping,
|
||||
..Default::default()
|
||||
},
|
||||
vec![],
|
||||
);
|
||||
|
||||
event.record_sync(&glean, get_timestamp_ms(), HashMap::new(), 12345);
|
||||
|
||||
let json = glean
|
||||
.event_storage()
|
||||
.snapshot_as_json(&glean, store_name, false)
|
||||
.unwrap();
|
||||
assert_eq!(json.as_array().unwrap().len(), 1);
|
||||
assert_eq!(json[0]["category"], "category");
|
||||
assert_eq!(json[0]["name"], "name");
|
||||
|
||||
let glean_timestamp = json[0]["extra"]["glean_timestamp"]
|
||||
.as_str()
|
||||
.expect("glean_timestamp should exist");
|
||||
let glean_timestamp: i64 = glean_timestamp
|
||||
.parse()
|
||||
.expect("glean_timestamp should be an integer");
|
||||
assert_eq!(12345, glean_timestamp);
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ fn events_ping_with_metric_but_no_events_is_not_sent() {
|
|||
},
|
||||
vec![],
|
||||
);
|
||||
event.record_sync(&glean, 0, HashMap::new());
|
||||
event.record_sync(&glean, 0, HashMap::new(), 0);
|
||||
|
||||
// Sending this should now succeed.
|
||||
assert!(events_ping.submit_sync(&glean, None));
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{"Cargo.toml":"6c5dc80704945076018237c096a850a6bd0d48d392e1f47e2d3437bdc673ea28","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5627cc81e6187ab6c2b4dff061af16d559edcab64ba786bac39daa69c703c595","src/common_test.rs":"de47b53dcca37985c0a2b8c02daecbf32309aa54f5a4dd9290719c2c1fd0fa55","src/configuration.rs":"5be1eaf4a2e1d1b35d9c13387f8f59b5f5d96a874b984396b7fae907e2938a8c","src/core_metrics.rs":"fef8fb4e5fa57c179836c6eb2cf59278fe3b8b036dbe57b0ff02971b4acd822f","src/lib.rs":"7bffe31c2b59d9e26b0869264af9a098be6eccb086f146e46777a288ad5e505f","src/net/http_uploader.rs":"43812a70d19a38e8d7a093c8076c2b6345372c3c861b0f3511428762700a65e0","src/net/mod.rs":"612a9f13ade0b202c8762bccc7b5dc288101cb3820e47be2755331911a221c55","src/private/event.rs":"02bbebf545695812e5055741cc0b5f3c99eda2039e684e26fcdd5f087ed15fe3","src/private/mod.rs":"eb8fe4e588bb32a54617324db39319920c627e6fc23c23cf4da5c17c63e0afed","src/private/ping.rs":"cbdc57f41fc9d46e56b4dfff91ac683753d1f8b3ecd0aa9bc3419e3595b8b81b","src/system.rs":"6eae5b41c15eba9cad6dbd116abe3519ee3e1fe034e79bdd692b029829a8c384","src/test.rs":"c877fa637e9049834818c3354f8b9b8b7a8136fb71ab3b0f9f0ea88115cbbd4b","tests/common/mod.rs":"08fb9483d9b6ed9fe873b4395245166ae8a15263be750c7a8e298c41d9604745","tests/init_fails.rs":"28fd7726e76ca1295eb0905eca0b2ec65b0accfa28432c9ff90ec8f92616fc79","tests/never_init.rs":"1f33b8ce7ca3514b57b48cc16d98408974c85cf8aa7d13257ffc2ad878ebb295","tests/no_time_to_init.rs":"e7df75b47897fbf2c860a2e1c1c225b57598b8d1a39125ca897fe8d825bf0338","tests/overflowing_preinit.rs":"7ad4b2274dd9240b53430859a4eb1d2597cf508a5a678333f3d3abbadd2ed4a7","tests/persist_ping_lifetime.rs":"81415dc1d74743f02269f0d0dfa524003147056853f080276972e64a0b761d3c","tests/persist_ping_lifetime_nopanic.rs":"18379d3ffbf4a2c8c684c04ff7a0660b86dfbbb447db2d24dfed6073cb7ddf8f","tests/schema.rs":"b1d78ac189c5f7309badbc37451fb428abce357e630a55e4ef5b0ef14d118f67","tests/simple.rs":"b099034b0599bdf4650e0fa09991a8413fc5fbf397755fc06c8963d4c7c8dfa6","tests/test-shutdown-blocking.sh":"9b16a01c190c7062474dd92182298a3d9a27928c8fa990340fdd798e6cdb7ab2","tests/test-thread-crashing.sh":"ff1bc8e5d7e4ba3a10d0d38bef222db8bfba469e7d30e45b1053d177a4084f09","tests/upload_timing.rs":"d044fce7c783133e385671ea37d674e5a1b4120cae7b07708dcd825addfa0ee3"},"package":"df470f5f41c8fc6113bd48fa18e0f1a8193e1e2b1f3942f8255b064e60db42ff"}
|
||||
{"files":{"Cargo.toml":"2042acbd7e091b5d46d2de0bd2e3eef92a62fc2e748a654e0a4f93106f3fb9ce","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5627cc81e6187ab6c2b4dff061af16d559edcab64ba786bac39daa69c703c595","src/common_test.rs":"de47b53dcca37985c0a2b8c02daecbf32309aa54f5a4dd9290719c2c1fd0fa55","src/configuration.rs":"136caf71560969cd404b51471cceca748bc9093bf8631d130670e163cdf1a1d1","src/core_metrics.rs":"fef8fb4e5fa57c179836c6eb2cf59278fe3b8b036dbe57b0ff02971b4acd822f","src/lib.rs":"fb007e2222c00fa02ee9dfc06fd4a965dcdfe92d79026bf722849b0e70b7c301","src/net/http_uploader.rs":"43812a70d19a38e8d7a093c8076c2b6345372c3c861b0f3511428762700a65e0","src/net/mod.rs":"612a9f13ade0b202c8762bccc7b5dc288101cb3820e47be2755331911a221c55","src/private/event.rs":"02bbebf545695812e5055741cc0b5f3c99eda2039e684e26fcdd5f087ed15fe3","src/private/mod.rs":"eb8fe4e588bb32a54617324db39319920c627e6fc23c23cf4da5c17c63e0afed","src/private/ping.rs":"cbdc57f41fc9d46e56b4dfff91ac683753d1f8b3ecd0aa9bc3419e3595b8b81b","src/system.rs":"6eae5b41c15eba9cad6dbd116abe3519ee3e1fe034e79bdd692b029829a8c384","src/test.rs":"c877fa637e9049834818c3354f8b9b8b7a8136fb71ab3b0f9f0ea88115cbbd4b","tests/common/mod.rs":"08fb9483d9b6ed9fe873b4395245166ae8a15263be750c7a8e298c41d9604745","tests/init_fails.rs":"28fd7726e76ca1295eb0905eca0b2ec65b0accfa28432c9ff90ec8f92616fc79","tests/never_init.rs":"1f33b8ce7ca3514b57b48cc16d98408974c85cf8aa7d13257ffc2ad878ebb295","tests/no_time_to_init.rs":"e7df75b47897fbf2c860a2e1c1c225b57598b8d1a39125ca897fe8d825bf0338","tests/overflowing_preinit.rs":"7ad4b2274dd9240b53430859a4eb1d2597cf508a5a678333f3d3abbadd2ed4a7","tests/persist_ping_lifetime.rs":"81415dc1d74743f02269f0d0dfa524003147056853f080276972e64a0b761d3c","tests/persist_ping_lifetime_nopanic.rs":"18379d3ffbf4a2c8c684c04ff7a0660b86dfbbb447db2d24dfed6073cb7ddf8f","tests/schema.rs":"b1d78ac189c5f7309badbc37451fb428abce357e630a55e4ef5b0ef14d118f67","tests/simple.rs":"b099034b0599bdf4650e0fa09991a8413fc5fbf397755fc06c8963d4c7c8dfa6","tests/test-shutdown-blocking.sh":"9b16a01c190c7062474dd92182298a3d9a27928c8fa990340fdd798e6cdb7ab2","tests/test-thread-crashing.sh":"ff1bc8e5d7e4ba3a10d0d38bef222db8bfba469e7d30e45b1053d177a4084f09","tests/upload_timing.rs":"d044fce7c783133e385671ea37d674e5a1b4120cae7b07708dcd825addfa0ee3"},"package":"5ca520309b2eb189c3834b4d9752286615a1cc04798715805a6da8f0d7f16941"}
|
|
@ -13,7 +13,7 @@
|
|||
edition = "2021"
|
||||
rust-version = "1.62"
|
||||
name = "glean"
|
||||
version = "53.2.0"
|
||||
version = "54.0.0"
|
||||
authors = [
|
||||
"Jan-Erik Rediger <jrediger@mozilla.com>",
|
||||
"The Glean Team <glean-team@mozilla.com>",
|
||||
|
@ -42,7 +42,7 @@ features = ["serde"]
|
|||
version = "0.5"
|
||||
|
||||
[dependencies.glean-core]
|
||||
version = "53.2.0"
|
||||
version = "54.0.0"
|
||||
|
||||
[dependencies.inherent]
|
||||
version = "1"
|
||||
|
|
|
@ -40,6 +40,8 @@ pub struct Configuration {
|
|||
pub log_level: Option<LevelFilter>,
|
||||
/// The rate pings may be uploaded before they are throttled.
|
||||
pub rate_limit: Option<crate::PingRateLimit>,
|
||||
/// (Experimental) Whether to add a wallclock timestamp to all events.
|
||||
pub enable_event_timestamps: bool,
|
||||
}
|
||||
|
||||
/// Configuration builder.
|
||||
|
@ -80,6 +82,8 @@ pub struct Builder {
|
|||
/// Optional: The internal ping upload rate limit.
|
||||
/// Default: `None`
|
||||
pub rate_limit: Option<crate::PingRateLimit>,
|
||||
/// (Experimental) Whether to add a wallclock timestamp to all events.
|
||||
pub enable_event_timestamps: bool,
|
||||
}
|
||||
|
||||
impl Builder {
|
||||
|
@ -101,6 +105,7 @@ impl Builder {
|
|||
trim_data_to_registered_pings: false,
|
||||
log_level: None,
|
||||
rate_limit: None,
|
||||
enable_event_timestamps: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,6 +123,7 @@ impl Builder {
|
|||
trim_data_to_registered_pings: self.trim_data_to_registered_pings,
|
||||
log_level: self.log_level,
|
||||
rate_limit: self.rate_limit,
|
||||
enable_event_timestamps: self.enable_event_timestamps,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,4 +162,10 @@ impl Builder {
|
|||
self.trim_data_to_registered_pings = value;
|
||||
self
|
||||
}
|
||||
|
||||
/// Set whether to add a wallclock timestamp to all events (experimental).
|
||||
pub fn with_event_timestamps(mut self, value: bool) -> Self {
|
||||
self.enable_event_timestamps = value;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,6 +120,7 @@ fn initialize_internal(cfg: Configuration, client_info: ClientInfoMetrics) -> Op
|
|||
trim_data_to_registered_pings: cfg.trim_data_to_registered_pings,
|
||||
log_level: cfg.log_level,
|
||||
rate_limit: cfg.rate_limit,
|
||||
enable_event_timestamps: cfg.enable_event_timestamps,
|
||||
};
|
||||
|
||||
glean_core::glean_initialize(core_cfg, client_info.into(), callbacks);
|
||||
|
|
|
@ -6,7 +6,7 @@ edition = "2018"
|
|||
license = "MPL-2.0"
|
||||
|
||||
[dependencies]
|
||||
glean = "53.2.0"
|
||||
glean = "54.0.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 = "53.2.0"
|
||||
glean = "54.0.0"
|
||||
inherent = "1.0.0"
|
||||
log = "0.4"
|
||||
nsstring = { path = "../../../../xpcom/rust/nsstring", optional = true }
|
||||
|
|
|
@ -41,6 +41,7 @@ fn setup_glean(tempdir: Option<tempfile::TempDir>) -> tempfile::TempDir {
|
|||
trim_data_to_registered_pings: false,
|
||||
log_level: None,
|
||||
rate_limit: None,
|
||||
enable_event_timestamps: false,
|
||||
};
|
||||
|
||||
let client_info = glean::ClientInfoMetrics {
|
||||
|
|
|
@ -178,6 +178,7 @@ fn build_configuration(
|
|||
trim_data_to_registered_pings: true,
|
||||
log_level: None,
|
||||
rate_limit,
|
||||
enable_event_timestamps: false,
|
||||
};
|
||||
|
||||
Ok((configuration, client_info))
|
||||
|
|
Загрузка…
Ссылка в новой задаче