mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-11 18:24:02 +00:00
Bug 1827399 - Update Glean to v52.5.0 r=janerik,supply-chain-reviewers
Depends on D174979 Differential Revision: https://phabricator.services.mozilla.com/D175174
This commit is contained in:
parent
38f4688935
commit
c2a5c87b71
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -2192,9 +2192,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "glean"
|
||||
version = "52.4.2"
|
||||
version = "52.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1bd184ec51a21129cb58a1b7380250d5f71de01b3461ab3b81594e0a2322123"
|
||||
checksum = "cd952afea9a760de2fc9f5d15f204f0ffa42178f8b77787d3b282c0b3dd1f398"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"crossbeam-channel",
|
||||
@ -2212,9 +2212,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "glean-core"
|
||||
version = "52.4.2"
|
||||
version = "52.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0e543be303977a73d720ce612a49937d5ba3fac9907d2e13556a32c67293d5e"
|
||||
checksum = "fe01fda83e8387e82f9b37f727870b9075e1e0dc9f7d061b40c76735ad238a22"
|
||||
dependencies = [
|
||||
"android_logger",
|
||||
"bincode",
|
||||
|
@ -36,7 +36,7 @@ allprojects {
|
||||
topsrcdir = gradle.mozconfig.topsrcdir
|
||||
topobjdir = gradle.mozconfig.topobjdir
|
||||
|
||||
gleanVersion = "52.4.2"
|
||||
gleanVersion = "52.5.0"
|
||||
if (gleanVersion != getRustVersionFor("glean")) {
|
||||
throw new StopExecutionException("Mismatched Glean version, expected: ${gleanVersion}," +
|
||||
" found ${getRustVersionFor("glean")}")
|
||||
|
8
gfx/wr/Cargo.lock
generated
8
gfx/wr/Cargo.lock
generated
@ -940,9 +940,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "glean"
|
||||
version = "52.4.2"
|
||||
version = "52.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1bd184ec51a21129cb58a1b7380250d5f71de01b3461ab3b81594e0a2322123"
|
||||
checksum = "cd952afea9a760de2fc9f5d15f204f0ffa42178f8b77787d3b282c0b3dd1f398"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"crossbeam-channel",
|
||||
@ -960,9 +960,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "glean-core"
|
||||
version = "52.4.2"
|
||||
version = "52.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0e543be303977a73d720ce612a49937d5ba3fac9907d2e13556a32c67293d5e"
|
||||
checksum = "fe01fda83e8387e82f9b37f727870b9075e1e0dc9f7d061b40c76735ad238a22"
|
||||
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 = "52.4.2"
|
||||
glean = "52.5.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 = "52.4.2", optional = true }
|
||||
glean = { version = "52.5.0", optional = true }
|
||||
firefox-on-glean = { version = "0.1.0", optional = true }
|
||||
serde = { optional = true, version = "1.0", features = ["serde_derive"] }
|
||||
|
||||
|
@ -137,7 +137,7 @@ pth:xpcom/geckoprocesstypes_generator
|
||||
pth:xpcom/idl-parser
|
||||
# glean-sdk may not be installable if a wheel isn't available
|
||||
# and it has to be built from source.
|
||||
pypi-optional:glean-sdk==52.4.2:telemetry will not be collected
|
||||
pypi-optional:glean-sdk==52.5.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).
|
||||
|
@ -9,15 +9,15 @@ user-login = "martinthomson"
|
||||
user-name = "Martin Thomson"
|
||||
|
||||
[[publisher.glean]]
|
||||
version = "52.4.2"
|
||||
when = "2023-03-15"
|
||||
version = "52.5.0"
|
||||
when = "2023-04-11"
|
||||
user-id = 48
|
||||
user-login = "badboy"
|
||||
user-name = "Jan-Erik Rediger"
|
||||
|
||||
[[publisher.glean-core]]
|
||||
version = "52.4.2"
|
||||
when = "2023-03-15"
|
||||
version = "52.5.0"
|
||||
when = "2023-04-11"
|
||||
user-id = 48
|
||||
user-login = "badboy"
|
||||
user-name = "Jan-Erik Rediger"
|
||||
|
File diff suppressed because one or more lines are too long
2
third_party/rust/glean-core/Cargo.toml
vendored
2
third_party/rust/glean-core/Cargo.toml
vendored
@ -13,7 +13,7 @@
|
||||
edition = "2021"
|
||||
rust-version = "1.62"
|
||||
name = "glean-core"
|
||||
version = "52.4.2"
|
||||
version = "52.5.0"
|
||||
authors = [
|
||||
"Jan-Erik Rediger <jrediger@mozilla.com>",
|
||||
"The Glean Team <glean-team@mozilla.com>",
|
||||
|
17
third_party/rust/glean-core/src/core/mod.rs
vendored
17
third_party/rust/glean-core/src/core/mod.rs
vendored
@ -12,7 +12,7 @@ use crate::event_database::EventDatabase;
|
||||
use crate::internal_metrics::{AdditionalMetrics, CoreMetrics, DatabaseMetrics};
|
||||
use crate::internal_pings::InternalPings;
|
||||
use crate::metrics::{
|
||||
self, ExperimentMetric, Metric, MetricType, MetricsDisabledConfig, PingType, RecordedExperiment,
|
||||
self, ExperimentMetric, Metric, MetricType, MetricsEnabledConfig, PingType, RecordedExperiment,
|
||||
};
|
||||
use crate::ping::PingMaker;
|
||||
use crate::storage::{StorageManager, INTERNAL_STORAGE};
|
||||
@ -153,7 +153,7 @@ pub struct Glean {
|
||||
pub(crate) app_build: String,
|
||||
pub(crate) schedule_metrics_pings: bool,
|
||||
pub(crate) remote_settings_epoch: AtomicU8,
|
||||
pub(crate) remote_settings_metrics_config: Arc<Mutex<MetricsDisabledConfig>>,
|
||||
pub(crate) remote_settings_metrics_config: Arc<Mutex<MetricsEnabledConfig>>,
|
||||
}
|
||||
|
||||
impl Glean {
|
||||
@ -207,7 +207,7 @@ impl Glean {
|
||||
// Subprocess doesn't use "metrics" pings so has no need for a scheduler.
|
||||
schedule_metrics_pings: false,
|
||||
remote_settings_epoch: AtomicU8::new(0),
|
||||
remote_settings_metrics_config: Arc::new(Mutex::new(MetricsDisabledConfig::new())),
|
||||
remote_settings_metrics_config: Arc::new(Mutex::new(MetricsEnabledConfig::new())),
|
||||
};
|
||||
|
||||
// Ensuring these pings are registered.
|
||||
@ -527,6 +527,7 @@ impl Glean {
|
||||
}
|
||||
|
||||
/// Gets a handle to the database.
|
||||
#[track_caller] // If this fails we're interested in the caller.
|
||||
pub fn storage(&self) -> &Database {
|
||||
self.data_store.as_ref().expect("No database found")
|
||||
}
|
||||
@ -702,14 +703,14 @@ impl Glean {
|
||||
metric.test_get_value(self)
|
||||
}
|
||||
|
||||
/// Set configuration for metrics' disabled property, typically from a remote_settings experiment
|
||||
/// or rollout
|
||||
/// Set configuration to override the default metric enabled/disabled state, typically from a
|
||||
/// remote_settings experiment or rollout
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `json` - The stringified JSON representation of a `MetricsDisabledConfig` object
|
||||
pub fn set_metrics_disabled_config(&self, cfg: MetricsDisabledConfig) {
|
||||
// Set the current MetricsDisabledConfig, keeping the lock until the epoch is
|
||||
/// * `json` - The stringified JSON representation of a `MetricsEnabledConfig` object
|
||||
pub fn set_metrics_enabled_config(&self, cfg: MetricsEnabledConfig) {
|
||||
// Set the current MetricsEnabledConfig, keeping the lock until the epoch is
|
||||
// updated to prevent against reading a "new" config but an "old" epoch
|
||||
let mut lock = self.remote_settings_metrics_config.lock().unwrap();
|
||||
*lock = cfg;
|
||||
|
15
third_party/rust/glean-core/src/database/mod.rs
vendored
15
third_party/rust/glean-core/src/database/mod.rs
vendored
@ -52,15 +52,12 @@ pub fn rkv_new(path: &Path) -> std::result::Result<Rkv, rkv::StoreError> {
|
||||
// Now try again, we only handle that error once.
|
||||
Rkv::new::<rkv::backend::SafeMode>(path)
|
||||
}
|
||||
// This code is currently disabled but intended to be turned on in the
|
||||
// near future. Please reference this bug for more details:
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1820792#c2
|
||||
// Err(rkv::StoreError::DatabaseCorrupted) => {
|
||||
// let safebin = path.join("data.safe.bin");
|
||||
// fs::remove_file(safebin).map_err(|_| rkv::StoreError::DatabaseCorrupted)?;
|
||||
// // Try again, only allowing the error once.
|
||||
// Rkv::new::<rkv::backend::SafeMode>(path)
|
||||
// }
|
||||
Err(rkv::StoreError::DatabaseCorrupted) => {
|
||||
let safebin = path.join("data.safe.bin");
|
||||
fs::remove_file(safebin).map_err(|_| rkv::StoreError::DatabaseCorrupted)?;
|
||||
// Try again, only allowing the error once.
|
||||
Rkv::new::<rkv::backend::SafeMode>(path)
|
||||
}
|
||||
other => other,
|
||||
}
|
||||
}
|
||||
|
@ -258,16 +258,21 @@ impl EventDatabase {
|
||||
/// monotonically increasing timer (this value is obtained on the
|
||||
/// platform-specific side).
|
||||
/// * `extra` - Extra data values, mapping strings to strings.
|
||||
///
|
||||
/// ## Returns
|
||||
///
|
||||
/// `true` if a ping was submitted and should be uploaded.
|
||||
/// `false` otherwise.
|
||||
pub fn record(
|
||||
&self,
|
||||
glean: &Glean,
|
||||
meta: &CommonMetricDataInternal,
|
||||
timestamp: u64,
|
||||
extra: Option<HashMap<String, String>>,
|
||||
) {
|
||||
) -> bool {
|
||||
// If upload is disabled we don't want to record.
|
||||
if !glean.is_upload_enabled() {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
let mut submit_max_capacity_event_ping = false;
|
||||
@ -303,6 +308,9 @@ impl EventDatabase {
|
||||
}
|
||||
if submit_max_capacity_event_ping {
|
||||
glean.submit_ping_by_name("events", Some("max_capacity"));
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
|
3
third_party/rust/glean-core/src/glean.udl
vendored
3
third_party/rust/glean-core/src/glean.udl
vendored
@ -29,6 +29,9 @@ namespace glean {
|
||||
void glean_set_experiment_inactive(string experiment_id);
|
||||
RecordedExperiment? glean_test_get_experiment_data(string experiment_id);
|
||||
|
||||
// Server Knobs API
|
||||
void glean_set_metrics_enabled_config(string json);
|
||||
|
||||
boolean glean_set_debug_view_tag(string tag);
|
||||
boolean glean_set_source_tags(sequence<string> tags);
|
||||
void glean_set_log_pings(boolean value);
|
||||
|
14
third_party/rust/glean-core/src/lib.rs
vendored
14
third_party/rust/glean-core/src/lib.rs
vendored
@ -28,7 +28,7 @@ use crossbeam_channel::unbounded;
|
||||
use once_cell::sync::{Lazy, OnceCell};
|
||||
use uuid::Uuid;
|
||||
|
||||
use metrics::MetricsDisabledConfig;
|
||||
use metrics::MetricsEnabledConfig;
|
||||
|
||||
mod common_metric_data;
|
||||
mod core;
|
||||
@ -170,6 +170,7 @@ static STATE: OnceCell<Mutex<State>> = OnceCell::new();
|
||||
/// Get a reference to the global state object.
|
||||
///
|
||||
/// Panics if no global state object was set.
|
||||
#[track_caller] // If this fails we're interested in the caller.
|
||||
fn global_state() -> &'static Mutex<State> {
|
||||
STATE.get().unwrap()
|
||||
}
|
||||
@ -772,13 +773,14 @@ pub fn glean_test_get_experiment_data(experiment_id: String) -> Option<RecordedE
|
||||
core::with_glean(|glean| glean.test_get_experiment_data(experiment_id.to_owned()))
|
||||
}
|
||||
|
||||
/// Sets a remote configuration for the metrics' disabled property
|
||||
/// Sets a remote configuration to override metrics' default enabled/disabled
|
||||
/// state
|
||||
///
|
||||
/// See [`core::Glean::set_metrics_disabled_config`].
|
||||
pub fn glean_set_metrics_disabled_config(json: String) {
|
||||
match MetricsDisabledConfig::try_from(json) {
|
||||
/// See [`core::Glean::set_metrics_enabled_config`].
|
||||
pub fn glean_set_metrics_enabled_config(json: String) {
|
||||
match MetricsEnabledConfig::try_from(json) {
|
||||
Ok(cfg) => launch_with_glean(|glean| {
|
||||
glean.set_metrics_disabled_config(cfg);
|
||||
glean.set_metrics_enabled_config(cfg);
|
||||
}),
|
||||
Err(e) => {
|
||||
log::error!("Error setting metrics feature config: {:?}", e);
|
||||
|
@ -852,15 +852,15 @@ fn test_set_metrics_disabled() {
|
||||
);
|
||||
|
||||
// 2. Set a configuration to disable the metrics
|
||||
let mut metrics_disabled_config = json!(
|
||||
let mut metrics_enabled_config = json!(
|
||||
{
|
||||
"category.string_metric": true,
|
||||
"category.labeled_string_metric": true,
|
||||
"category.string_metric": false,
|
||||
"category.labeled_string_metric": false,
|
||||
}
|
||||
)
|
||||
.to_string();
|
||||
glean.set_metrics_disabled_config(
|
||||
MetricsDisabledConfig::try_from(metrics_disabled_config).unwrap(),
|
||||
glean.set_metrics_enabled_config(
|
||||
MetricsEnabledConfig::try_from(metrics_enabled_config).unwrap(),
|
||||
);
|
||||
|
||||
// 3. Since the metrics were disabled, setting a new value will be ignored
|
||||
@ -883,9 +883,9 @@ fn test_set_metrics_disabled() {
|
||||
);
|
||||
|
||||
// 4. Set a new configuration where the metrics are enabled
|
||||
metrics_disabled_config = json!({}).to_string();
|
||||
glean.set_metrics_disabled_config(
|
||||
MetricsDisabledConfig::try_from(metrics_disabled_config).unwrap(),
|
||||
metrics_enabled_config = json!({}).to_string();
|
||||
glean.set_metrics_enabled_config(
|
||||
MetricsEnabledConfig::try_from(metrics_enabled_config).unwrap(),
|
||||
);
|
||||
|
||||
// 5. Since the metrics are now enabled, setting a new value should work
|
||||
@ -917,14 +917,14 @@ fn test_remote_settings_epoch() {
|
||||
assert_eq!(0u8, current_epoch, "Current epoch must start at 0");
|
||||
|
||||
// 2. Set a configuration which will trigger incrementing the epoch
|
||||
let metrics_disabled_config = json!(
|
||||
let metrics_enabled_config = json!(
|
||||
{
|
||||
"category.string_metric": true
|
||||
"category.string_metric": false
|
||||
}
|
||||
)
|
||||
.to_string();
|
||||
glean.set_metrics_disabled_config(
|
||||
MetricsDisabledConfig::try_from(metrics_disabled_config).unwrap(),
|
||||
glean.set_metrics_enabled_config(
|
||||
MetricsEnabledConfig::try_from(metrics_enabled_config).unwrap(),
|
||||
);
|
||||
|
||||
// 3. Ensure the epoch updated
|
||||
@ -951,14 +951,14 @@ fn test_remote_settings_epoch_updates_in_metric() {
|
||||
);
|
||||
|
||||
// 2. Set a configuration to disable the `category.string_metric`
|
||||
let metrics_disabled_config = json!(
|
||||
let metrics_enabled_config = json!(
|
||||
{
|
||||
"category.string_metric": true
|
||||
"category.string_metric": false
|
||||
}
|
||||
)
|
||||
.to_string();
|
||||
glean.set_metrics_disabled_config(
|
||||
MetricsDisabledConfig::try_from(metrics_disabled_config).unwrap(),
|
||||
glean.set_metrics_enabled_config(
|
||||
MetricsEnabledConfig::try_from(metrics_enabled_config).unwrap(),
|
||||
);
|
||||
|
||||
// 3. Ensure the epoch was updated
|
||||
|
28
third_party/rust/glean-core/src/metrics/event.rs
vendored
28
third_party/rust/glean-core/src/metrics/event.rs
vendored
@ -68,7 +68,15 @@ 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();
|
||||
crate::launch_with_glean(move |glean| metric.record_sync(glean, timestamp, extra));
|
||||
crate::launch_with_glean(move |glean| {
|
||||
let sent = metric.record_sync(glean, timestamp, extra);
|
||||
if sent {
|
||||
let state = crate::global_state().lock().unwrap();
|
||||
if let Err(e) = state.callbacks.trigger_upload() {
|
||||
log::error!("Triggering upload failed. Error: {}", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Validate that extras are empty or all extra keys are allowed.
|
||||
@ -104,20 +112,30 @@ impl EventMetric {
|
||||
}
|
||||
|
||||
/// Records an event.
|
||||
///
|
||||
/// ## Returns
|
||||
///
|
||||
/// `true` if a ping was submitted and should be uploaded.
|
||||
/// `false` otherwise.
|
||||
#[doc(hidden)]
|
||||
pub fn record_sync(&self, glean: &Glean, timestamp: u64, extra: HashMap<String, String>) {
|
||||
pub fn record_sync(
|
||||
&self,
|
||||
glean: &Glean,
|
||||
timestamp: u64,
|
||||
extra: HashMap<String, String>,
|
||||
) -> bool {
|
||||
if !self.should_record(glean) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
let extra_strings = match self.validate_extra(glean, extra) {
|
||||
Ok(extra) => extra,
|
||||
Err(()) => return,
|
||||
Err(()) => return false,
|
||||
};
|
||||
|
||||
glean
|
||||
.event_storage()
|
||||
.record(glean, &self.meta, timestamp, extra_strings);
|
||||
.record(glean, &self.meta, timestamp, extra_strings)
|
||||
}
|
||||
|
||||
/// **Test-only API (exported for FFI purposes).**
|
||||
|
@ -112,9 +112,14 @@ impl MemoryDistributionMetric {
|
||||
sample = MAX_BYTES;
|
||||
}
|
||||
|
||||
glean
|
||||
.storage()
|
||||
.record_with(glean, &self.meta, |old_value| match old_value {
|
||||
// Let's be defensive here:
|
||||
// The uploader tries to store some memory distribution metrics,
|
||||
// but in tests that storage might be gone already.
|
||||
// Let's just ignore those.
|
||||
// We do the same for counters and timing distributions.
|
||||
// This should never happen in real app usage.
|
||||
if let Some(storage) = glean.storage_opt() {
|
||||
storage.record_with(glean, &self.meta, |old_value| match old_value {
|
||||
Some(Metric::MemoryDistribution(mut hist)) => {
|
||||
hist.accumulate(sample);
|
||||
Metric::MemoryDistribution(hist)
|
||||
@ -125,6 +130,12 @@ impl MemoryDistributionMetric {
|
||||
Metric::MemoryDistribution(hist)
|
||||
}
|
||||
});
|
||||
} else {
|
||||
log::warn!(
|
||||
"Couldn't get storage. Can't record memory distribution '{}'.",
|
||||
self.meta.base_identifier()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Accumulates the provided signed samples in the metric.
|
||||
|
@ -6,31 +6,35 @@ use std::{collections::HashMap, convert::TryFrom};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Represents a list of metrics and their associated `disabled` property from the
|
||||
/// remote-settings configuration store. The expected format of this data is stringified
|
||||
/// JSON in the following format:
|
||||
/// Represents a list of metrics and an associated boolean property
|
||||
/// indicating if the metric is enabledfrom the remote-settings
|
||||
/// configuration store. The expected format of this data is stringified JSON
|
||||
/// in the following format:
|
||||
/// ```json
|
||||
/// {
|
||||
/// "category.metric_name": true
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
|
||||
pub struct MetricsDisabledConfig {
|
||||
pub struct MetricsEnabledConfig {
|
||||
/// This is a `HashMap` consisting of base_identifiers as keys
|
||||
/// and bool values representing an override for the `disabled`
|
||||
/// property of the metric
|
||||
/// property of the metric, only inverted to reduce confusion.
|
||||
/// If a particular metric has a value of `true` here, it means
|
||||
/// the default of the metric will be overriden and set to the
|
||||
/// enabled state.
|
||||
#[serde(flatten)]
|
||||
pub metrics_disabled: HashMap<String, bool>,
|
||||
pub metrics_enabled: HashMap<String, bool>,
|
||||
}
|
||||
|
||||
impl MetricsDisabledConfig {
|
||||
/// Creates a new MetricsDisabledConfig
|
||||
impl MetricsEnabledConfig {
|
||||
/// Creates a new MetricsEnabledConfig
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<String> for MetricsDisabledConfig {
|
||||
impl TryFrom<String> for MetricsEnabledConfig {
|
||||
type Error = crate::ErrorKind;
|
||||
|
||||
fn try_from(json: String) -> Result<Self, Self::Error> {
|
15
third_party/rust/glean-core/src/metrics/mod.rs
vendored
15
third_party/rust/glean-core/src/metrics/mod.rs
vendored
@ -21,7 +21,7 @@ mod experiment;
|
||||
pub(crate) mod labeled;
|
||||
mod memory_distribution;
|
||||
mod memory_unit;
|
||||
mod metrics_disabled_config;
|
||||
mod metrics_enabled_config;
|
||||
mod numerator;
|
||||
mod ping;
|
||||
mod quantity;
|
||||
@ -69,7 +69,7 @@ pub use self::uuid::UuidMetric;
|
||||
pub use crate::histogram::HistogramType;
|
||||
pub use recorded_experiment::RecordedExperiment;
|
||||
|
||||
pub use self::metrics_disabled_config::MetricsDisabledConfig;
|
||||
pub use self::metrics_enabled_config::MetricsEnabledConfig;
|
||||
|
||||
/// A snapshot of all buckets and the accumulated sum of a distribution.
|
||||
//
|
||||
@ -195,11 +195,11 @@ pub trait MetricType {
|
||||
}
|
||||
// The epoch's didn't match so we need to look up the disabled flag
|
||||
// by the base_identifier from the in-memory HashMap
|
||||
let metrics_disabled = &glean
|
||||
let metrics_enabled = &glean
|
||||
.remote_settings_metrics_config
|
||||
.lock()
|
||||
.unwrap()
|
||||
.metrics_disabled;
|
||||
.metrics_enabled;
|
||||
// Get the value from the remote configuration if it is there, otherwise return the default value.
|
||||
let current_disabled = {
|
||||
let base_id = self.meta().base_identifier();
|
||||
@ -207,8 +207,11 @@ pub trait MetricType {
|
||||
.split_once('/')
|
||||
.map(|split| split.0)
|
||||
.unwrap_or(&base_id);
|
||||
if let Some(is_disabled) = metrics_disabled.get(identifier) {
|
||||
u8::from(*is_disabled)
|
||||
// NOTE: The `!` preceding the `*is_enabled` is important for inverting the logic since the
|
||||
// underlying property in the metrics.yaml is `disabled` and the outward API is treating it as
|
||||
// if it were `enabled` to make it easier to understand.
|
||||
if let Some(is_enabled) = metrics_enabled.get(identifier) {
|
||||
u8::from(!*is_enabled)
|
||||
} else {
|
||||
u8::from(self.meta().inner.disabled)
|
||||
}
|
||||
|
15
third_party/rust/glean-core/src/upload/mod.rs
vendored
15
third_party/rust/glean-core/src/upload/mod.rs
vendored
@ -21,11 +21,15 @@ use std::sync::{Arc, RwLock, RwLockWriteGuard};
|
||||
use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use chrono::Utc;
|
||||
|
||||
use crate::error::ErrorKind;
|
||||
use crate::TimerId;
|
||||
use crate::{internal_metrics::UploadMetrics, Glean};
|
||||
use directory::{PingDirectoryManager, PingPayloadsByDirectory};
|
||||
use policy::Policy;
|
||||
use request::create_date_header_value;
|
||||
|
||||
pub use request::{HeaderMap, PingRequest};
|
||||
pub use result::{UploadResult, UploadTaskAction};
|
||||
|
||||
@ -605,9 +609,14 @@ impl PingUploadManager {
|
||||
in_flight.insert(request.document_id.clone(), (success_id, failure_id));
|
||||
}
|
||||
|
||||
PingUploadTask::Upload {
|
||||
request: queue.pop_front().unwrap(),
|
||||
}
|
||||
let mut request = queue.pop_front().unwrap();
|
||||
|
||||
// Adding the `Date` header just before actual upload happens.
|
||||
request
|
||||
.headers
|
||||
.insert("Date".to_string(), create_date_header_value(Utc::now()));
|
||||
|
||||
PingUploadTask::Upload { request }
|
||||
}
|
||||
None => {
|
||||
log::info!("No more pings to upload! You are done.");
|
||||
|
@ -18,7 +18,7 @@ use crate::system;
|
||||
pub type HeaderMap = HashMap<String, String>;
|
||||
|
||||
/// Creates a formatted date string that can be used with Date headers.
|
||||
fn create_date_header_value(current_time: DateTime<Utc>) -> String {
|
||||
pub(crate) fn create_date_header_value(current_time: DateTime<Utc>) -> String {
|
||||
// Date headers are required to be in the following format:
|
||||
//
|
||||
// <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
|
||||
@ -68,7 +68,6 @@ impl Builder {
|
||||
/// Creates a new builder for a PingRequest.
|
||||
pub fn new(language_binding_name: &str, body_max_size: usize) -> Self {
|
||||
let mut headers = HashMap::new();
|
||||
headers.insert("Date".to_string(), create_date_header_value(Utc::now()));
|
||||
headers.insert(
|
||||
"X-Telemetry-Agent".to_string(),
|
||||
create_x_telemetry_agent_header_value(
|
||||
@ -265,10 +264,12 @@ mod test {
|
||||
assert_eq!(request.path, "/random/path/doesnt/matter");
|
||||
|
||||
// Make sure all the expected headers were added.
|
||||
assert!(request.headers.contains_key("Date"));
|
||||
assert!(request.headers.contains_key("X-Telemetry-Agent"));
|
||||
assert!(request.headers.contains_key("Content-Type"));
|
||||
assert!(request.headers.contains_key("Content-Length"));
|
||||
|
||||
// the `Date` header is added by the `get_upload_task` just before
|
||||
// returning the upload request
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
2
third_party/rust/glean/.cargo-checksum.json
vendored
2
third_party/rust/glean/.cargo-checksum.json
vendored
@ -1 +1 @@
|
||||
{"files":{"Cargo.toml":"794cb4c811e030330df0a32cc2dcc5778e9749ae69857e90fef4061f61a973b5","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5627cc81e6187ab6c2b4dff061af16d559edcab64ba786bac39daa69c703c595","src/common_test.rs":"de47b53dcca37985c0a2b8c02daecbf32309aa54f5a4dd9290719c2c1fd0fa55","src/configuration.rs":"4ca9be0a49a9c50f4ebe868d4bfa04fe27619c871a436911f850b4dcf6e7a7b2","src/core_metrics.rs":"dd17b482613894af08b51a2cff6dc1e84a6dbd853c14a55566e6698348941ced","src/lib.rs":"2eb1b09f2f8a649729cd27222f0889eed7b50940fc7e2bb27de54abbdac439df","src/net/http_uploader.rs":"43812a70d19a38e8d7a093c8076c2b6345372c3c861b0f3511428762700a65e0","src/net/mod.rs":"e36e170a8e53530f8705988eea694ed7c55f50bb0ce403c0facbfb75ce03ac7f","src/private/event.rs":"02bbebf545695812e5055741cc0b5f3c99eda2039e684e26fcdd5f087ed15fe3","src/private/mod.rs":"0364ecf5f0439443a5b209583f4ff2c474b79f7c253c981ab0b7cdc528368698","src/private/ping.rs":"cbdc57f41fc9d46e56b4dfff91ac683753d1f8b3ecd0aa9bc3419e3595b8b81b","src/system.rs":"6eae5b41c15eba9cad6dbd116abe3519ee3e1fe034e79bdd692b029829a8c384","src/test.rs":"d367c85a106df58272b8a779da1769664ba8a39357fd650d9f21c21855b38906","tests/common/mod.rs":"37cd4c48e140c793b852ae09fb3e812da28a4412977295015bcbffd632fcf294","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":"ea93fcf68e00ae803031dba9b93edac0713f17e375287c32c35512ba69d5f100","tests/simple.rs":"b099034b0599bdf4650e0fa09991a8413fc5fbf397755fc06c8963d4c7c8dfa6","tests/test-shutdown-blocking.sh":"9b16a01c190c7062474dd92182298a3d9a27928c8fa990340fdd798e6cdb7ab2","tests/upload_timing.rs":"d044fce7c783133e385671ea37d674e5a1b4120cae7b07708dcd825addfa0ee3"},"package":"e1bd184ec51a21129cb58a1b7380250d5f71de01b3461ab3b81594e0a2322123"}
|
||||
{"files":{"Cargo.toml":"0e3ae5c53f426d43d6a6106c8cbeb980805376447d9f54155550770979127f2f","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5627cc81e6187ab6c2b4dff061af16d559edcab64ba786bac39daa69c703c595","src/common_test.rs":"de47b53dcca37985c0a2b8c02daecbf32309aa54f5a4dd9290719c2c1fd0fa55","src/configuration.rs":"4ca9be0a49a9c50f4ebe868d4bfa04fe27619c871a436911f850b4dcf6e7a7b2","src/core_metrics.rs":"dd17b482613894af08b51a2cff6dc1e84a6dbd853c14a55566e6698348941ced","src/lib.rs":"6b486cda2c92ab49dbc26533f1aac5b0b1a071b227ddd9b9e85c0edb768fe5bc","src/net/http_uploader.rs":"43812a70d19a38e8d7a093c8076c2b6345372c3c861b0f3511428762700a65e0","src/net/mod.rs":"e36e170a8e53530f8705988eea694ed7c55f50bb0ce403c0facbfb75ce03ac7f","src/private/event.rs":"02bbebf545695812e5055741cc0b5f3c99eda2039e684e26fcdd5f087ed15fe3","src/private/mod.rs":"0364ecf5f0439443a5b209583f4ff2c474b79f7c253c981ab0b7cdc528368698","src/private/ping.rs":"cbdc57f41fc9d46e56b4dfff91ac683753d1f8b3ecd0aa9bc3419e3595b8b81b","src/system.rs":"6eae5b41c15eba9cad6dbd116abe3519ee3e1fe034e79bdd692b029829a8c384","src/test.rs":"d367c85a106df58272b8a779da1769664ba8a39357fd650d9f21c21855b38906","tests/common/mod.rs":"37cd4c48e140c793b852ae09fb3e812da28a4412977295015bcbffd632fcf294","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":"1b7b19aec54a24c2bdd4738cf33c16802c19c83504c4d0e6bcfc19142877acdb","tests/simple.rs":"b099034b0599bdf4650e0fa09991a8413fc5fbf397755fc06c8963d4c7c8dfa6","tests/test-shutdown-blocking.sh":"9b16a01c190c7062474dd92182298a3d9a27928c8fa990340fdd798e6cdb7ab2","tests/upload_timing.rs":"d044fce7c783133e385671ea37d674e5a1b4120cae7b07708dcd825addfa0ee3"},"package":"cd952afea9a760de2fc9f5d15f204f0ffa42178f8b77787d3b282c0b3dd1f398"}
|
4
third_party/rust/glean/Cargo.toml
vendored
4
third_party/rust/glean/Cargo.toml
vendored
@ -13,7 +13,7 @@
|
||||
edition = "2021"
|
||||
rust-version = "1.62"
|
||||
name = "glean"
|
||||
version = "52.4.2"
|
||||
version = "52.5.0"
|
||||
authors = [
|
||||
"Jan-Erik Rediger <jrediger@mozilla.com>",
|
||||
"The Glean Team <glean-team@mozilla.com>",
|
||||
@ -43,7 +43,7 @@ features = ["serde"]
|
||||
version = "0.5"
|
||||
|
||||
[dependencies.glean-core]
|
||||
version = "52.4.2"
|
||||
version = "52.5.0"
|
||||
|
||||
[dependencies.inherent]
|
||||
version = "1"
|
||||
|
6
third_party/rust/glean/src/lib.rs
vendored
6
third_party/rust/glean/src/lib.rs
vendored
@ -170,9 +170,9 @@ pub fn set_experiment_inactive(experiment_id: String) {
|
||||
|
||||
/// Set the remote configuration values for the metrics' disabled property
|
||||
///
|
||||
/// See [`glean_core::Glean::set_metrics_disabled_config`].
|
||||
pub fn glean_set_metrics_disabled_config(json: String) {
|
||||
glean_core::glean_set_metrics_disabled_config(json)
|
||||
/// See [`glean_core::Glean::set_metrics_enabled_config`].
|
||||
pub fn glean_set_metrics_enabled_config(json: String) {
|
||||
glean_core::glean_set_metrics_enabled_config(json)
|
||||
}
|
||||
|
||||
/// Performs the collection/cleanup operations required by becoming active.
|
||||
|
4
third_party/rust/glean/tests/schema.rs
vendored
4
third_party/rust/glean/tests/schema.rs
vendored
@ -115,6 +115,10 @@ fn validate_against_schema() {
|
||||
stringlist_metric.add("one".into());
|
||||
stringlist_metric.add("two".into());
|
||||
|
||||
// Let's make sure an empty array is accepted.
|
||||
let stringlist_metric2 = StringListMetric::new(common("stringlist2"));
|
||||
stringlist_metric2.set(vec![]);
|
||||
|
||||
let timespan_metric = TimespanMetric::new(common("timespan"), TimeUnit::Nanosecond);
|
||||
timespan_metric.start();
|
||||
timespan_metric.stop();
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "MPL-2.0"
|
||||
|
||||
[dependencies]
|
||||
glean = "52.4.2"
|
||||
glean = "52.5.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 = "52.4.2"
|
||||
glean = "52.5.0"
|
||||
inherent = "1.0.0"
|
||||
log = "0.4"
|
||||
nsstring = { path = "../../../../xpcom/rust/nsstring", optional = true }
|
||||
|
Loading…
x
Reference in New Issue
Block a user