Skip to content

Commit

Permalink
Bump the string length limit to 255 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
badboy committed Jun 3, 2024
1 parent aa34cbd commit c22dbe2
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

[Full changelog](https://github.com/mozilla/glean/compare/v60.3.0...main)

* General
* Bump the string length limit to 255 characters ([#2857](https://github.com/mozilla/glean/pull/2857))

# v60.3.0 (2024-05-31)

[Full changelog](https://github.com/mozilla/glean/compare/v60.2.0...v60.3.0)
Expand Down
3 changes: 2 additions & 1 deletion docs/user/reference/metrics/string.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ Glean.searchDefault.name.set("wikipedia");

#### Limits

* Fixed maximum string length: 100. Longer strings are truncated. This is measured in the number of bytes when the string is encoded in UTF-8.
* Fixed maximum string length: 255. Longer strings are truncated. This is measured in the number of bytes when the string is encoded in UTF-8.
* Prior to Glean v60.4.0 the limit was 100 bytes.

## Testing API

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class StringMetricTypeTest {
),
)

stringMetric.set("0123456789".repeat(11))
stringMetric.set("0123456789".repeat(26))

assertEquals(1, stringMetric.testGetNumRecordedErrors(ErrorType.INVALID_OVERFLOW))
}
Expand Down
2 changes: 1 addition & 1 deletion glean-core/ios/GleanTests/Metrics/StringMetricTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class StringMetricTests: XCTestCase {
disabled: false
))

stringMetric.set(String(repeating: "0123456789", count: 11))
stringMetric.set(String(repeating: "0123456789", count: 26))

XCTAssertEqual(1, stringMetric.testGetNumRecordedErrors(.invalidOverflow))
}
Expand Down
2 changes: 1 addition & 1 deletion glean-core/python/tests/metrics/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_setting_a_long_string_records_an_error():
)
)

string_metric.set("0123456789" * 11)
string_metric.set("0123456789" * 26)

assert 1 == string_metric.test_get_num_recorded_errors(testing.ErrorType.INVALID_OVERFLOW)

Expand Down
4 changes: 2 additions & 2 deletions glean-core/src/metrics/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::util::truncate_string_at_boundary_with_error;
use crate::CommonMetricData;
use crate::Glean;

const MAX_LENGTH_VALUE: usize = 100;
const MAX_LENGTH_VALUE: usize = 255;

/// A string metric.
///
Expand Down Expand Up @@ -166,7 +166,7 @@ mod test {
dynamic_label: None,
});

let sample_string = "0123456789".repeat(11);
let sample_string = "0123456789".repeat(26);
metric.set_sync(&glean, sample_string.clone());

let truncated = truncate_string_at_boundary(sample_string, MAX_LENGTH_VALUE);
Expand Down
2 changes: 1 addition & 1 deletion glean-core/tests/labeled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ fn can_record_error_for_submetric() {
);

let metric = labeled.get("label1");
metric.set_sync(&glean, "01234567890".repeat(20));
metric.set_sync(&glean, "01234567890".repeat(26));

// Make sure that the errors have been recorded
assert_eq!(
Expand Down
6 changes: 3 additions & 3 deletions glean-core/tests/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ fn long_string_values_are_truncated() {
..Default::default()
});

let test_sting = "01234567890".repeat(20);
metric.set_sync(&glean, test_sting.clone());
let test_string = "01234567890".repeat(26);
metric.set_sync(&glean, test_string.clone());

// Check that data was truncated
assert_eq!(
test_sting[..100],
test_string[..255],
metric.get_value(&glean, "store1").unwrap()
);

Expand Down

0 comments on commit c22dbe2

Please sign in to comment.