Skip to content

Commit

Permalink
Bug 1729723 - Update Glean to 41.0.0 r=TravisLong
Browse files Browse the repository at this point in the history
  • Loading branch information
chutten committed Sep 16, 2021
1 parent 2ebb482 commit 17a1456
Show file tree
Hide file tree
Showing 22 changed files with 617 additions and 60 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ allprojects {
topsrcdir = gradle.mozconfig.topsrcdir
topobjdir = gradle.mozconfig.topobjdir

gleanVersion = "40.1.0"
gleanVersion = "41.0.0"
if (gleanVersion != getRustVersionFor("glean")) {
throw new StopExecutionException("Mismatched Glean version, expected: ${gleanVersion}," +
" found ${getRustVersionFor("glean")}")
Expand Down
2 changes: 1 addition & 1 deletion third_party/rust/glean-core/.cargo-checksum.json

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions third_party/rust/glean-core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions third_party/rust/glean-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.

[package]
edition = "2018"
name = "glean-core"
version = "40.1.0"
version = "41.0.0"
authors = ["Jan-Erik Rediger <[email protected]>", "The Glean Team <[email protected]>"]
include = ["/README.md", "/LICENSE", "/src", "/examples", "/tests", "/Cargo.toml"]
description = "A modern Telemetry library"
Expand All @@ -22,7 +21,7 @@ keywords = ["telemetry"]
license = "MPL-2.0"
repository = "https://github.com/mozilla/glean"
[package.metadata.glean]
glean-parser = "3.6.0"
glean-parser = "4.0.0"
[dependencies.bincode]
version = "1.2.1"

Expand Down
67 changes: 66 additions & 1 deletion third_party/rust/glean-core/src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ impl Database {
ping_lifetime_data
.write()
.expect("Can't access ping lifetime data as writable")
.clear();
.retain(|metric_id, _| !metric_id.starts_with(storage_name));
}

self.write_with_store(Lifetime::Ping, |mut writer, store| {
Expand Down Expand Up @@ -1321,6 +1321,71 @@ mod test {
}
}

#[test]
fn test_delayed_ping_lifetime_clear() {
// Init the database in a temporary directory.
let dir = tempdir().unwrap();
let db = Database::new(dir.path(), true).unwrap();
let test_storage = "test-storage";

assert!(db.ping_lifetime_data.is_some());

// Attempt to record a known value.
let test_value1 = "test-value1";
let test_metric_id1 = "telemetry_test.test_name1";
db.record_per_lifetime(
Lifetime::Ping,
test_storage,
test_metric_id1,
&Metric::String(test_value1.to_string()),
)
.unwrap();

{
let data = match &db.ping_lifetime_data {
Some(ping_lifetime_data) => ping_lifetime_data,
None => panic!("Expected `ping_lifetime_data` to exist here!"),
};
let data = data.read().unwrap();
// Verify that test_value1 is in memory.
assert!(data
.get(&format!("{}#{}", test_storage, test_metric_id1))
.is_some());
}

// Clear ping lifetime storage for a storage that isn't test_storage.
// Doesn't matter what it's called, just that it isn't test_storage.
db.clear_ping_lifetime_storage(&(test_storage.to_owned() + "x"))
.unwrap();

{
let data = match &db.ping_lifetime_data {
Some(ping_lifetime_data) => ping_lifetime_data,
None => panic!("Expected `ping_lifetime_data` to exist here!"),
};
let data = data.read().unwrap();
// Verify that test_value1 is still in memory.
assert!(data
.get(&format!("{}#{}", test_storage, test_metric_id1))
.is_some());
}

// Clear test_storage's ping lifetime storage.
db.clear_ping_lifetime_storage(test_storage).unwrap();

{
let data = match &db.ping_lifetime_data {
Some(ping_lifetime_data) => ping_lifetime_data,
None => panic!("Expected `ping_lifetime_data` to exist here!"),
};
let data = data.read().unwrap();
// Verify that test_value1 is no longer in memory.
assert!(data
.get(&format!("{}#{}", test_storage, test_metric_id1))
.is_none());
}
}

#[test]
fn doesnt_record_when_upload_is_disabled() {
let (mut glean, dir) = new_glean(None);
Expand Down
1 change: 1 addition & 0 deletions third_party/rust/glean-core/src/lib_unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ fn correct_order() {
MemoryDistribution(..) => assert_eq!(12, disc),
Jwe(..) => assert_eq!(13, disc),
Rate(..) => assert_eq!(14, disc),
Url(..) => assert_eq!(15, disc),
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions third_party/rust/glean-core/src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mod string_list;
mod time_unit;
mod timespan;
mod timing_distribution;
mod url;
mod uuid;

pub use crate::event_database::RecordedEvent;
Expand Down Expand Up @@ -63,6 +64,7 @@ pub use self::time_unit::TimeUnit;
pub use self::timespan::TimespanMetric;
pub use self::timing_distribution::TimerId;
pub use self::timing_distribution::TimingDistributionMetric;
pub use self::url::UrlMetric;
pub use self::uuid::UuidMetric;

/// A snapshot of all buckets and the accumulated sum of a distribution.
Expand Down Expand Up @@ -121,6 +123,8 @@ pub enum Metric {
Jwe(String),
/// A rate metric. See [`RateMetric`] for more information.
Rate(i32, i32),
/// A URL metric. See [`UrlMetric`] for more information.
Url(String),
}

/// A [`MetricType`] describes common behavior across all metrics.
Expand Down Expand Up @@ -160,6 +164,7 @@ impl Metric {
Metric::StringList(_) => "string_list",
Metric::Timespan(..) => "timespan",
Metric::TimingDistribution(_) => "timing_distribution",
Metric::Url(_) => "url",
Metric::Uuid(_) => "uuid",
Metric::MemoryDistribution(_) => "memory_distribution",
Metric::Jwe(_) => "jwe",
Expand Down Expand Up @@ -187,6 +192,7 @@ impl Metric {
json!({"value": time_unit.duration_convert(*time), "time_unit": time_unit})
}
Metric::TimingDistribution(hist) => json!(timing_distribution::snapshot(hist)),
Metric::Url(s) => json!(s),
Metric::Uuid(s) => json!(s),
Metric::MemoryDistribution(hist) => json!(memory_distribution::snapshot(hist)),
Metric::Jwe(s) => json!(s),
Expand Down
Loading

0 comments on commit 17a1456

Please sign in to comment.