mod common;
use glean::Configuration;
mod metrics {
use glean::private::*;
use glean::Lifetime;
use glean_core::CommonMetricData;
use once_cell::sync::Lazy;
#[allow(non_upper_case_globals)]
pub static rapid_counting: Lazy<CounterMetric> = Lazy::new(|| {
CounterMetric::new(CommonMetricData {
name: "rapid_counting".into(),
category: "sample".into(),
send_in_pings: vec!["metrics".into()],
lifetime: Lifetime::Ping,
disabled: false,
..Default::default()
})
});
#[allow(non_upper_case_globals)]
pub static preinit_tasks_overflow: Lazy<CounterMetric> = Lazy::new(|| {
CounterMetric::new(CommonMetricData {
category: "glean.error".into(),
name: "preinit_tasks_overflow".into(),
send_in_pings: vec!["metrics".into()],
lifetime: Lifetime::Ping,
disabled: false,
..Default::default()
})
});
}
#[test]
fn overflowing_the_task_queue_records_telemetry() {
common::enable_test_logging();
let dir = tempfile::tempdir().unwrap();
let tmpname = dir.path().to_path_buf();
let cfg = Configuration {
data_path: tmpname,
application_id: "firefox-desktop".into(),
upload_enabled: true,
max_events: None,
delay_ping_lifetime_io: false,
server_endpoint: Some("invalid-test-host".into()),
uploader: None,
use_core_mps: false,
};
for _ in 0..1010 {
metrics::rapid_counting.add(1);
}
common::initialize(cfg);
assert_eq!(Some(1000), metrics::rapid_counting.test_get_value(None));
let val = metrics::preinit_tasks_overflow
.test_get_value(None)
.unwrap();
assert!(val >= 10);
glean::shutdown();
}