Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1828528 - add TextMetric entry to private mod.rs #2451

Merged
merged 1 commit into from
Apr 19, 2023
Merged
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
1 change: 1 addition & 0 deletions glean-core/rlb/src/private/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub use glean_core::RateMetric;
pub use glean_core::RecordedExperiment;
pub use glean_core::StringListMetric;
pub use glean_core::StringMetric;
pub use glean_core::TextMetric;
pub use glean_core::TimespanMetric;
pub use glean_core::TimingDistributionMetric;
pub use glean_core::UrlMetric;
Expand Down
27 changes: 26 additions & 1 deletion glean-core/rlb/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use flate2::read::GzDecoder;
use serde_json::Value as JsonValue;

use crate::private::PingType;
use crate::private::{BooleanMetric, CounterMetric, EventMetric, StringMetric};
use crate::private::{BooleanMetric, CounterMetric, EventMetric, StringMetric, TextMetric};

use super::*;
use crate::common_test::{lock_test, new_glean, GLOBAL_APPLICATION_ID};
Expand Down Expand Up @@ -1369,6 +1369,31 @@ fn test_boolean_get_num_errors() {
assert_eq!(result, 0);
}

#[test]
fn test_text_can_hold_long_string() {
let _lock = lock_test();

let _t = new_glean(None, false);

let metric = TextMetric::new(CommonMetricData {
name: "text_metric".into(),
category: "test".into(),
send_in_pings: vec!["custom1".into()],
lifetime: Lifetime::Application,
disabled: false,
dynamic_label: Some(str::to_string("text")),
});

// 216 characters, which would overflow StringMetric
metric.set("I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhäuser Gate. All those moments will be lost in time, like tears in rain".into());

let result = metric.test_get_num_recorded_errors(ErrorType::InvalidValue);
assert_eq!(result, 0);

let result = metric.test_get_num_recorded_errors(ErrorType::InvalidOverflow);
assert_eq!(result, 0);
}

#[test]
fn signaling_done() {
let _lock = lock_test();
Expand Down