Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions glean-core/rlb-tests/src/bin/delayed-ping-data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use flate2::read::GzDecoder;
use glean::{ClientInfoMetrics, ConfigurationBuilder, net, private::PingType};

pub mod glean_metrics {
use glean::{CommonMetricData, Lifetime, private::CounterMetric};
use glean::{CommonMetricData, Lifetime, private::*};

#[allow(non_upper_case_globals)]
pub static sample_counter: once_cell::sync::Lazy<CounterMetric> =
Expand All @@ -27,6 +27,24 @@ pub mod glean_metrics {
..Default::default()
})
});

#[allow(non_upper_case_globals)]
pub static labeled_counter: once_cell::sync::Lazy<LabeledMetric<CounterMetric>> =
once_cell::sync::Lazy::new(|| {
LabeledMetric::new(
glean::LabeledMetricData::Common {
cmd: CommonMetricData {
name: "labeled_counter".into(),
category: "test.metrics".into(),
send_in_pings: vec!["prototype".into()],
disabled: false,
lifetime: Lifetime::Ping,
..Default::default()
},
},
None,
)
});
}

#[derive(Debug)]
Expand Down Expand Up @@ -123,11 +141,13 @@ fn main() {
match &*state {
"accumulate_one_and_pretend_crash" => {
log::debug!("incrementing by 1. exiting without shutdown.");
glean_metrics::sample_counter.add(1)
glean_metrics::sample_counter.add(1);
glean_metrics::labeled_counter.get("label").add(1);
}
"accumulate_ten_and_orderly_shutdown" => {
log::debug!("incrementing by 10, waiting, shutdown. should trigger a flush.");
glean_metrics::sample_counter.add(10);
glean_metrics::labeled_counter.get("label").add(10);
glean::shutdown();
}
"submit_ping" => {
Expand Down
4 changes: 4 additions & 0 deletions glean-core/rlb-tests/tests/it.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ fn delayed_ping_data() {
let mut lines = payload.lines();
assert!(lines.any(|line| line.contains("\"url\":") && line.contains("/prototype/")));
assert!(payload.contains("\"test.metrics.sample_counter\":10"));
assert!(
payload.contains("\"test.metrics.labeled_counter\":{\"label\":10}}}"),
"{payload}"
);
}

#[cfg(unix)]
Expand Down
Loading
Loading